@@ -16,6 +16,9 @@ Deno.test("getRemoteContains", async (t) => {
16
16
"returns undefined if no remote contains the commitish" ,
17
17
async ( ) => {
18
18
const executeStub = stub ( _internals , "execute" , ( args , _options ) => {
19
+ if ( args . at ( 0 ) === "remote" ) {
20
+ return Promise . resolve ( "origin\nfork\n" ) ;
21
+ }
19
22
if ( args . at ( 0 ) === "branch" ) {
20
23
return Promise . resolve ( "\n" ) ;
21
24
}
@@ -34,6 +37,9 @@ Deno.test("getRemoteContains", async (t) => {
34
37
"returns 'origin' if 'origin/my-awesome-branch' contains the commitish" ,
35
38
async ( ) => {
36
39
const executeStub = stub ( _internals , "execute" , ( args , _options ) => {
40
+ if ( args . at ( 0 ) === "remote" ) {
41
+ return Promise . resolve ( "origin\nfork\n" ) ;
42
+ }
37
43
if ( args . at ( 0 ) === "branch" ) {
38
44
return Promise . resolve ( "origin/my-awesome-branch\n" ) ;
39
45
}
@@ -52,11 +58,35 @@ Deno.test("getRemoteContains", async (t) => {
52
58
"returns 'origin' if 'origin/HEAD' and 'origin/my-awesome-branch' contains the commitish" ,
53
59
async ( ) => {
54
60
const executeStub = stub ( _internals , "execute" , ( args , _options ) => {
61
+ if ( args . at ( 0 ) === "remote" ) {
62
+ return Promise . resolve ( "origin\nfork\n" ) ;
63
+ }
55
64
if ( args . at ( 0 ) === "branch" ) {
56
65
return Promise . resolve ( "origin/HEAD\norigin/my-awesome-branch\n" ) ;
57
66
}
58
67
unreachable ( ) ;
59
68
} ) ;
69
+ try {
70
+ const remote = await getRemoteContains ( "<<commitish>>" ) ;
71
+ assertEquals ( remote , "origin" ) ;
72
+ } finally {
73
+ executeStub . restore ( ) ;
74
+ }
75
+ } ,
76
+ ) ;
77
+
78
+ await t . step (
79
+ "returns 'fork' if 'fork/my-awesome-branch' contains the commitish" ,
80
+ async ( ) => {
81
+ const executeStub = stub ( _internals , "execute" , ( args , _options ) => {
82
+ if ( args . at ( 0 ) === "remote" ) {
83
+ return Promise . resolve ( "origin\nfork\n" ) ;
84
+ }
85
+ if ( args . at ( 0 ) === "branch" ) {
86
+ return Promise . resolve ( "fork/my-awesome-branch\n" ) ;
87
+ }
88
+ unreachable ( ) ;
89
+ } ) ;
60
90
try {
61
91
const remote = await getRemoteContains ( "<<commitish>>" ) ;
62
92
assertEquals ( remote , "fork" ) ;
@@ -65,6 +95,73 @@ Deno.test("getRemoteContains", async (t) => {
65
95
}
66
96
} ,
67
97
) ;
98
+
99
+ await t . step (
100
+ "returns 'origin' if 'origin/feature/my-awesome-branch' contains the commitish (#9)" ,
101
+ async ( ) => {
102
+ const executeStub = stub ( _internals , "execute" , ( args , _options ) => {
103
+ if ( args . at ( 0 ) === "remote" ) {
104
+ return Promise . resolve ( "origin\nfork\n" ) ;
105
+ }
106
+ if ( args . at ( 0 ) === "branch" ) {
107
+ return Promise . resolve ( "origin/feature/my-awesome-branch\n" ) ;
108
+ }
109
+ unreachable ( ) ;
110
+ } ) ;
111
+ try {
112
+ const remote = await getRemoteContains ( "<<commitish>>" ) ;
113
+ assertEquals ( remote , "origin" ) ;
114
+ } finally {
115
+ executeStub . restore ( ) ;
116
+ }
117
+ } ,
118
+ ) ;
119
+
120
+ await t . step (
121
+ "returns 'fork/my-awesome-fork' if 'fork/my-awesome-fork/feature/my-awesome-branch' contains the commitish" ,
122
+ async ( ) => {
123
+ const executeStub = stub ( _internals , "execute" , ( args , _options ) => {
124
+ if ( args . at ( 0 ) === "remote" ) {
125
+ return Promise . resolve ( "origin\nfork/my-awesome-fork\n" ) ;
126
+ }
127
+ if ( args . at ( 0 ) === "branch" ) {
128
+ return Promise . resolve (
129
+ "fork/my-awesome-fork/feature/my-awesome-branch\n" ,
130
+ ) ;
131
+ }
132
+ unreachable ( ) ;
133
+ } ) ;
134
+ try {
135
+ const remote = await getRemoteContains ( "<<commitish>>" ) ;
136
+ assertEquals ( remote , "fork/my-awesome-fork" ) ;
137
+ } finally {
138
+ executeStub . restore ( ) ;
139
+ }
140
+ } ,
141
+ ) ;
142
+
143
+ await t . step (
144
+ "returns 'origin' if 'origin/my-awesome-branch' and 'fork/my-awesome-branch' contains the commitish" ,
145
+ async ( ) => {
146
+ const executeStub = stub ( _internals , "execute" , ( args , _options ) => {
147
+ if ( args . at ( 0 ) === "remote" ) {
148
+ return Promise . resolve ( "origin\nfork\n" ) ;
149
+ }
150
+ if ( args . at ( 0 ) === "branch" ) {
151
+ return Promise . resolve (
152
+ "fork/my-awesome-branch\norigin/my-awesome-branch\n" ,
153
+ ) ;
154
+ }
155
+ unreachable ( ) ;
156
+ } ) ;
157
+ try {
158
+ const remote = await getRemoteContains ( "<<commitish>>" ) ;
159
+ assertEquals ( remote , "origin" ) ;
160
+ } finally {
161
+ executeStub . restore ( ) ;
162
+ }
163
+ } ,
164
+ ) ;
68
165
} ) ;
69
166
70
167
Deno . test ( "getRemoteFetchURL" , async ( t ) => {
0 commit comments