@@ -4,19 +4,28 @@ import {IGitSourceSettings} from 'github-checkout/lib/git-source-settings'
44
55export interface IGitHelper {
66 branchContainsTag ( tag : string ) : Promise < string >
7- branchExists ( remote : boolean , pattern : string ) : Promise < boolean >
7+ branchExists (
8+ remote : boolean ,
9+ remoteName : string ,
10+ pattern : string
11+ ) : Promise < boolean >
812 checkout ( ref : string , startPoint : string ) : Promise < void >
9- checkoutToBranch ( remote : boolean , branch : string ) : Promise < boolean >
13+ checkoutToBranch (
14+ remote : boolean ,
15+ remoteName : string ,
16+ branch : string
17+ ) : Promise < boolean >
1018 commitAll ( ) : Promise < void >
1119 currentBranch ( ) : Promise < string >
1220 currentRevision ( ) : Promise < string >
1321 currentTag ( ) : Promise < string | undefined >
22+ fetchRemote ( remoteName : string , fetchDepth ?: number ) : Promise < void >
1423 hasChanges ( ) : Promise < boolean >
1524 init ( ) : Promise < void >
1625 lastMatchingTag ( pattern : string ) : Promise < string | undefined >
17- pull ( remote : boolean , branch : string ) : Promise < void >
26+ pull ( remoteName : string , branch : string ) : Promise < void >
1827 push ( remote : string , branch : string ) : Promise < void >
19- remoteAdd ( isRemote : boolean , remoteName : string ) : Promise < void >
28+ remoteAdd ( remote : boolean , remoteName : string ) : Promise < void >
2029 remoteExists ( remote : string ) : Promise < boolean >
2130 revisionDate ( ref : string ) : Promise < Date >
2231 tag ( tag : string ) : Promise < void >
@@ -65,15 +74,15 @@ export class GitHelper implements IGitHelper {
6574 }
6675 }
6776
68- async branchExists ( remote : boolean , pattern : string ) : Promise < boolean > {
69- if ( remote ) {
70- return await this . gitCommandManager . branchExists (
71- remote ,
72- `origin/ ${ pattern } `
73- )
74- }
75-
76- return await this . gitCommandManager . branchExists ( remote , pattern )
77+ async branchExists (
78+ remote : boolean ,
79+ remoteName : string ,
80+ pattern : string
81+ ) : Promise < boolean > {
82+ return await this . gitCommandManager . branchExists (
83+ remote ,
84+ remoteName ? ` ${ remoteName } / ${ pattern } ` : pattern
85+ )
7786 }
7887
7988 async checkout ( ref : string , startPoint : string ) : Promise < void > {
@@ -85,17 +94,15 @@ export class GitHelper implements IGitHelper {
8594 return await this . gitCommandManager . checkout ( ref , startPoint )
8695 }
8796
88- async checkoutToBranch ( remote : boolean , branch : string ) : Promise < boolean > {
89- let branchExists : boolean
90-
91- if ( remote ) {
92- branchExists = await this . gitCommandManager . branchExists (
93- true ,
94- `origin/${ branch } `
95- )
96- } else {
97- branchExists = await this . gitCommandManager . branchExists ( false , branch )
98- }
97+ async checkoutToBranch (
98+ remote : boolean ,
99+ remoteName : string ,
100+ branch : string
101+ ) : Promise < boolean > {
102+ const branchExists = await this . gitCommandManager . branchExists (
103+ remote ,
104+ remote ? `${ remoteName } /${ branch } ` : branch
105+ )
99106
100107 if ( branchExists ) {
101108 await this . gitCommandManager . checkout ( branch , '' )
@@ -130,6 +137,10 @@ export class GitHelper implements IGitHelper {
130137 }
131138 }
132139
140+ async fetchRemote ( remoteName : string , fetchDepth ?: number ) : Promise < void > {
141+ return this . gitCommandManager . fetchRemote ( remoteName , fetchDepth )
142+ }
143+
133144 async hasChanges ( ) : Promise < boolean > {
134145 const result = await this . gitCommandManager . statusPorcelain ( )
135146
@@ -174,25 +185,23 @@ export class GitHelper implements IGitHelper {
174185 return undefined
175186 }
176187
177- async pull ( remote : boolean , branch : string ) : Promise < void > {
178- if ( remote ) {
179- return this . gitCommandManager . pull ( 'origin' , branch )
180- }
181-
182- return this . gitCommandManager . pull ( '' , branch )
188+ async pull ( remoteName : string , branch : string ) : Promise < void > {
189+ // await this.gitCommandManager.stash()
190+ await this . gitCommandManager . pull ( remoteName , branch )
191+ // return this.gitCommandManager.stashPop()
183192 }
184193
185194 async push ( remote : string , branch : string ) : Promise < void > {
186195 return this . gitCommandManager . push ( remote , branch )
187196 }
188197
189- async remoteAdd ( isRemote : boolean , remoteName : string ) : Promise < void > {
198+ async remoteAdd ( remote : boolean , remoteName : string ) : Promise < void > {
190199 const qualifiedRepository = this . qualifiedRepository ( )
191200 let fetchUri = await this . gitCommandManager . tryGetFetchUrl ( )
192201
193- if ( isRemote && fetchUri && ! fetchUri . endsWith ( qualifiedRepository ) ) {
202+ if ( remote && fetchUri && ! fetchUri . endsWith ( qualifiedRepository ) ) {
194203 const baseUrl = fetchUri . split ( this . settings . repositoryOwner ) [ 0 ]
195- fetchUri = `${ baseUrl } / ${ qualifiedRepository } .git`
204+ fetchUri = `${ baseUrl } ${ qualifiedRepository } .git`
196205 }
197206
198207 return this . gitCommandManager . remoteAdd ( remoteName , fetchUri )
0 commit comments