@@ -47,13 +47,16 @@ const parseRepo: (repo: string, cred: auth.credentials) => string = (repo: strin
4747 return `${ part [ 0 ] } ://${ cred . login } :${ cred . auth } @${ part . slice ( 1 ) . join ( "://" ) } ` ;
4848}
4949
50- export const pull : ( repo : string , skipNotify ?: boolean ) => void = async ( repo : string , skipNotify : boolean = false ) => {
50+ export const pull : ( repo : string , branch ?: string , skipNotify ?: boolean ) => Promise < void > = async ( repo : string , branch : string = "main" , skipNotify : boolean = false ) => {
5151 if ( isNull ( repo ) ) return ;
5252
5353 const dist : Distribution = extension . distribution ( ) ;
5454 const cred : auth . credentials | undefined = auth . authorization ( ) ;
5555
56- if ( ! cred ) return skipNotify || auth . authenticate ( ) ;
56+ if ( ! cred ) {
57+ skipNotify || auth . authenticate ( ) ;
58+ return ;
59+ }
5760
5861 // init directory
5962
@@ -65,13 +68,11 @@ export const pull: (repo: string, skipNotify?: boolean) => void = async (repo: s
6568
6669 const remote : string = parseRepo ( repo , cred ) ;
6770
68- const branch : string = config . get ( "branch" ) ?? "main" ;
69-
7071 // callback
7172
7273 const gitback : ( err : GitError | null ) => void = ( err : GitError | null ) => {
7374 if ( err ) {
74- logger . error ( `Failed to pull from ${ config . get ( "repository" ) } :\n ${ auth . mask ( err . message , cred ) } ` , true ) ;
75+ logger . error ( `Failed to pull from ${ repo } @ ${ branch } :\n ${ auth . mask ( err . message , cred ) } ` , true ) ;
7576 cleanup ( temp ) ;
7677 }
7778 } ;
@@ -80,7 +81,7 @@ export const pull: (repo: string, skipNotify?: boolean) => void = async (repo: s
8081
8182 statusbar . setActive ( true ) ;
8283
83- logger . info ( `Preparing to import settings from ${ config . get ( "repository" ) } @${ branch } ` ) ;
84+ logger . info ( `Preparing to import settings from ${ repo } @${ branch } ` ) ;
8485 logger . debug ( `Git clone ${ auth . mask ( remote , cred ) } ` ) ;
8586
8687 // forced delay so git repo can get up-to-date after a fast reload/restart
@@ -148,21 +149,21 @@ export const pull: (repo: string, skipNotify?: boolean) => void = async (repo: s
148149 logger . warn ( "Snippets not found" ) ;
149150 }
150151
151- logger . info ( `Imported settings from ${ config . get ( "repository" ) } @${ branch } ` , true ) ;
152+ logger . info ( `Imported settings from ${ repo } @${ branch } ` , true ) ;
152153
153154 cleanup ( temp ) ;
154155
155156 skipNotify || extension . notify ( ) ;
156157 }
157158 } ) ;
158159 } catch ( error : any ) {
159- logger . error ( `Push failed: ${ auth . mask ( error , cred ) } ` , true ) ;
160+ logger . error ( `Pull failed: ${ auth . mask ( String ( error ?. message ?? error ) , cred ) } ` , true ) ;
160161 } finally {
161162 cleanup ( temp ) ;
162163 }
163164}
164165
165- export const push : ( repo : string , ignoreBadAuth ?: boolean ) => Promise < void > = async ( repo : string , ignoreBadAuth : boolean = false ) => {
166+ export const push : ( repo : string , branch ?: string , ignoreBadAuth ?: boolean ) => Promise < void > = async ( repo : string , branch : string = "main" , ignoreBadAuth : boolean = false ) => {
166167 if ( isNull ( repo ) ) return ;
167168
168169 const dist : Distribution = extension . distribution ( ) ;
@@ -180,13 +181,11 @@ export const push: (repo: string, ignoreBadAuth?: boolean) => Promise<void> = as
180181
181182 const remote : string = parseRepo ( repo , cred ) ;
182183
183- const branch : string = config . get ( "branch" ) ?? "main" ;
184-
185184 // callback
186185
187186 const gitback : ( err : GitError | null ) => void = ( err : GitError | null ) => {
188187 if ( err ) {
189- logger . error ( `Failed to push to ${ config . get ( "repository" ) } :\n ${ auth . mask ( err . message , cred ) } ` , true ) ;
188+ logger . error ( `Failed to push to ${ repo } @ ${ branch } :\n ${ auth . mask ( err . message , cred ) } ` , true ) ;
190189 cleanup ( temp ) ;
191190 }
192191 } ;
@@ -195,7 +194,7 @@ export const push: (repo: string, ignoreBadAuth?: boolean) => Promise<void> = as
195194
196195 statusbar . setActive ( true ) ;
197196
198- logger . info ( `Preparing to export settings to ${ config . get ( "repository" ) } @${ branch } ` ) ;
197+ logger . info ( `Preparing to export settings to ${ repo } @${ branch } ` ) ;
199198 logger . debug ( `Git clone ${ auth . mask ( remote , cred ) } ` ) ;
200199 logger . debug ( `includeHostnameInCommit: ${ config . get ( "includeHostnameInCommitMessage" ) } ` ) ;
201200
@@ -257,7 +256,7 @@ export const push: (repo: string, ignoreBadAuth?: boolean) => Promise<void> = as
257256 }
258257 } catch ( error : any ) {
259258 if ( error ) {
260- logger . error ( `Push failed: ${ auth . mask ( error , cred ) } ` , true ) ;
259+ logger . error ( `Push failed: ${ auth . mask ( String ( error ) , cred ) } ` , true ) ;
261260 cleanup ( temp ) ;
262261 }
263262 }
@@ -271,12 +270,12 @@ export const push: (repo: string, ignoreBadAuth?: boolean) => Promise<void> = as
271270 . push ( [ "-u" , "origin" , "HEAD" ] , ( err : GitError | null ) => {
272271 gitback ( err ) ;
273272 if ( ! err ) {
274- logger . info ( `Pushed settings to ${ config . get ( "repository" ) } @${ branch } ` , true ) ;
273+ logger . info ( `Pushed settings to ${ repo } @${ branch } ` , true ) ;
275274 cleanup ( temp ) ;
276275 }
277276 } ) ;
278277 } catch ( error : any ) {
279- logger . error ( `Push failed: ${ auth . mask ( error , cred ) } ` , true ) ;
278+ logger . error ( `Push failed: ${ auth . mask ( String ( error ?. message ?? error ) , cred ) } ` , true ) ;
280279 } finally {
281280 cleanup ( temp ) ;
282281 }
0 commit comments