@@ -34,6 +34,14 @@ export interface GitHttpAuth {
3434 password : string ;
3535}
3636
37+ interface GitSyncSuccessResult {
38+ success : boolean ;
39+ message : string ;
40+ remote ?: string ;
41+ branch ?: string ;
42+ updated ?: boolean ;
43+ }
44+
3745export interface GitAuthFailureDetails {
3846 operation : "push" | "pull" | "fetch" ;
3947 remote ?: string ;
@@ -306,7 +314,7 @@ export async function runGitPush(
306314 force ?: boolean ;
307315 auth ?: GitHttpAuth ;
308316 }
309- ) : Promise < { success : boolean ; message : string } > {
317+ ) : Promise < GitSyncSuccessResult > {
310318 const args = [ "push" ] ;
311319 let remote = options ?. remote ;
312320 let branch = options ?. branch ;
@@ -335,6 +343,8 @@ export async function runGitPush(
335343 remote = ( await getPreferredRemote ( cwd ) ) ?? undefined ;
336344 }
337345
346+ const summaryBranch = branch ?? ( await getCurrentBranchName ( cwd ) ) ;
347+
338348 if ( remote && branch ) {
339349 args . push ( remote , `HEAD:${ branch } ` ) ;
340350 } else if ( remote ) {
@@ -355,10 +365,13 @@ export async function runGitPush(
355365 await persistGitHttpCredentials ( cwd , options . auth , remoteMetadata ) ;
356366 }
357367
358- // Combine output for message
359- const message = stdout || stderr || "Push completed successfully" ;
360-
361- return { success : true , message } ;
368+ return {
369+ success : true ,
370+ message : "Push completed successfully" ,
371+ remote,
372+ branch : summaryBranch ,
373+ updated : ! isPushUpToDate ( stdout , stderr ) ,
374+ } ;
362375 } catch ( error ) {
363376 throw normalizeGitAuthFailure ( error , {
364377 operation : "push" ,
@@ -381,7 +394,7 @@ export async function runGitPull(
381394 branch ?: string ;
382395 auth ?: GitHttpAuth ;
383396 }
384- ) : Promise < { success : boolean ; message : string ; updatedFiles ?: string [ ] } > {
397+ ) : Promise < GitSyncSuccessResult & { updatedFiles ?: string [ ] } > {
385398 const args = [ "pull" ] ;
386399 let remote = options ?. remote ;
387400 let branch = options ?. branch ;
@@ -396,6 +409,8 @@ export async function runGitPull(
396409 remote = ( await getPreferredRemote ( cwd ) ) ?? "origin" ;
397410 }
398411
412+ const summaryBranch = branch ?? ( await getCurrentBranchName ( cwd ) ) ;
413+
399414 if ( remote && branch ) {
400415 args . push ( remote , branch ) ;
401416 }
@@ -430,9 +445,14 @@ export async function runGitPull(
430445 }
431446 }
432447
433- const message = stdout || stderr || "Pull completed successfully" ;
434-
435- return { success : true , message, updatedFiles } ;
448+ return {
449+ success : true ,
450+ message : "Pull completed successfully" ,
451+ remote,
452+ branch : summaryBranch ,
453+ updated : ! isPullUpToDate ( stdout , stderr ) ,
454+ updatedFiles,
455+ } ;
436456 } catch ( error ) {
437457 throw normalizeGitAuthFailure ( error , {
438458 operation : "pull" ,
@@ -707,6 +727,24 @@ async function resolveRemoteBranchTarget(
707727 }
708728}
709729
730+ async function getCurrentBranchName ( cwd : string ) : Promise < string | undefined > {
731+ try {
732+ const { stdout } = await runGit ( cwd , [ "branch" , "--show-current" ] ) ;
733+ const branch = stdout . trim ( ) ;
734+ return branch || undefined ;
735+ } catch {
736+ return undefined ;
737+ }
738+ }
739+
740+ function isPushUpToDate ( stdout : string , stderr : string ) : boolean {
741+ return / E v e r y t h i n g u p - t o - d a t e / i. test ( `${ stdout } \n${ stderr } ` ) ;
742+ }
743+
744+ function isPullUpToDate ( stdout : string , stderr : string ) : boolean {
745+ return / A l r e a d y u p [ - ] t o [ - ] d a t e \. ? / i. test ( `${ stdout } \n${ stderr } ` ) ;
746+ }
747+
710748async function getPreferredRemote ( cwd : string ) : Promise < string | null > {
711749 try {
712750 const { stdout } = await runGit ( cwd , [ "remote" ] ) ;
0 commit comments