@@ -4192,7 +4192,7 @@ Let's work through this together to get CI passing.`
41924192 progress . startPhase ( 'commit-and-push' )
41934193 log . step ( 'Committing and pushing changes' )
41944194
4195- // Check for changes
4195+ // Check for uncommitted changes
41964196 const statusResult = await runCommandWithOutput (
41974197 'git' ,
41984198 [ 'status' , '--porcelain' ] ,
@@ -4201,6 +4201,16 @@ Let's work through this together to get CI passing.`
42014201 } ,
42024202 )
42034203
4204+ // Check if local branch is ahead of remote (unpushed commits)
4205+ const revListResult = await runCommandWithOutput (
4206+ 'git' ,
4207+ [ 'rev-list' , '@{upstream}..HEAD' , '--count' ] ,
4208+ {
4209+ cwd : rootPath ,
4210+ } ,
4211+ )
4212+ const unpushedCount = Number . parseInt ( revListResult . stdout . trim ( ) || '0' , 10 )
4213+
42044214 if ( statusResult . stdout . trim ( ) ) {
42054215 log . progress ( 'Changes detected, committing' )
42064216
@@ -4242,8 +4252,32 @@ Let's work through this together to get CI passing.`
42424252 await runCommand ( 'git' , [ 'push' ] , { cwd : rootPath } )
42434253 log . done ( 'Changes pushed to remote' )
42444254 }
4255+ } else if ( unpushedCount > 0 ) {
4256+ log . info (
4257+ `No uncommitted changes, but ${ unpushedCount } unpushed commit(s) detected` ,
4258+ )
4259+
4260+ if ( isDryRun ) {
4261+ log . done ( '[DRY RUN] Would push unpushed commits' )
4262+ } else {
4263+ log . progress ( 'Pushing unpushed commits' )
4264+
4265+ // Validate before pushing
4266+ const validation = await validateBeforePush ( rootPath )
4267+ if ( ! validation . valid ) {
4268+ log . warn ( 'Pre-push validation warnings:' )
4269+ validation . warnings . forEach ( warning => {
4270+ log . substep ( warning )
4271+ } )
4272+ log . substep ( 'Continuing with push (warnings are non-blocking)...' )
4273+ }
4274+
4275+ // Push
4276+ await runCommand ( 'git' , [ 'push' ] , { cwd : rootPath } )
4277+ log . done ( 'Unpushed commits pushed to remote' )
4278+ }
42454279 } else {
4246- log . info ( 'No changes to commit' )
4280+ log . info ( 'No changes to commit and no unpushed commits ' )
42474281 }
42484282
42494283 // End commit phase.
@@ -4409,13 +4443,25 @@ Let's work through this together to get CI passing.`
44094443 // Filter runs to find one matching our commit SHA or recent push
44104444 let matchingRun = null
44114445
4412- // First, try exact SHA match
4446+ // Debug: log current SHA and available runs
4447+ if ( pollAttempt === 0 ) {
4448+ log . substep (
4449+ `Looking for workflow runs for commit ${ currentSha . substring ( 0 , 7 ) } ` ,
4450+ )
4451+ if ( runs . length > 0 ) {
4452+ log . substep ( `Found ${ runs . length } recent runs, checking for matches...` )
4453+ }
4454+ }
4455+
4456+ // First, try exact SHA match (both directions for robustness)
44134457 for ( const run of runs ) {
4414- if ( run . headSha ?. startsWith ( currentSha . substring ( 0 , 7 ) ) ) {
4458+ if (
4459+ run . headSha === currentSha ||
4460+ run . headSha ?. startsWith ( currentSha . substring ( 0 , 7 ) ) ||
4461+ currentSha . startsWith ( run . headSha ?. substring ( 0 , 7 ) || '' )
4462+ ) {
44154463 matchingRun = run
4416- log . substep (
4417- `Found exact match for commit ${ currentSha . substring ( 0 , 7 ) } ` ,
4418- )
4464+ log . substep ( `Found SHA match for commit ${ currentSha . substring ( 0 , 7 ) } ` )
44194465 break
44204466 }
44214467 }
@@ -4425,10 +4471,10 @@ Let's work through this together to get CI passing.`
44254471 for ( const run of runs ) {
44264472 if ( run . createdAt ) {
44274473 const runTime = new Date ( run . createdAt ) . getTime ( )
4428- // Check if run was created within 2 minutes after push
4474+ // Check if run was created within 2 minutes BEFORE or after push
44294475 if ( runTime >= pushTime - 120_000 ) {
44304476 matchingRun = run
4431- log . substep ( `Found workflow started after push: ${ run . name } ` )
4477+ log . substep ( `Found workflow started around push time : ${ run . name } ` )
44324478 break
44334479 }
44344480 }
@@ -4440,8 +4486,8 @@ Let's work through this together to get CI passing.`
44404486 const newestRun = runs [ 0 ]
44414487 if ( newestRun . createdAt ) {
44424488 const runTime = new Date ( newestRun . createdAt ) . getTime ( )
4443- // Only consider if created within last 5 minutes
4444- if ( Date . now ( ) - runTime < 5 * 60 * 1000 ) {
4489+ // Only consider if created within last 10 minutes
4490+ if ( Date . now ( ) - runTime < 10 * 60 * 1000 ) {
44454491 matchingRun = newestRun
44464492 log . substep ( `Monitoring recent workflow: ${ newestRun . name } ` )
44474493 }
0 commit comments