@@ -243,35 +243,34 @@ SKIP_EOF
243243 echo " ::notice::Skipping commit (already upstream): $rebase_head_oneline "
244244 fi
245245 CONFLICTS_SKIPPED=$(( CONFLICTS_SKIPPED + 1 ))
246- git rebase --skip
246+ git rebase --skip || :
247247 ;;
248248 continue)
249249 echo " ::notice::Resolved conflict surgically: $rebase_head_oneline "
250250 CONFLICTS_RESOLVED=$(( CONFLICTS_RESOLVED + 1 ))
251- GIT_EDITOR=: git rebase --continue
252-
253- # Verify build after surgical resolution
251+
252+ # Verify build before committing the resolution
254253 echo " ::group::Verifying build"
255254 if ! make -j$( nproc) 2>&1 | tee make.log; then
256255 echo " ::endgroup::"
257256 echo " ::warning::Build failed after conflict resolution, giving AI another chance"
258257
259258 local retry_prompt=" Build failed after your conflict resolution. Fix the compilation error.
260259
261- Files you modified : $( git diff --name-only HEAD^ )
260+ Files with conflicts : $( git diff --name-only --diff-filter=U )
262261
263262Investigation:
264263- See full build log: view make.log
265- - See your changes: git diff HEAD^
266- - Edit files to fix, then: git add <file> && git commit --amend --no-edit
264+ - See your changes: git diff
265+ - Edit files to fix, then: git add <file>
267266
268267Build errors (last 15 lines):
269268$( tail -15 make.log)
270269
271270Output 'continue' when fixed, or 'fail' if you cannot fix it.
272271Your FINAL line must be exactly: continue or fail"
273272
274- local retry_output=$( run_copilot " $retry_prompt " ' shell(git commit --amend) ' )
273+ local retry_output=$( run_copilot " $retry_prompt " )
275274 local retry_exit_code=$?
276275
277276 echo " ::group::AI Retry Output"
@@ -288,7 +287,7 @@ Your FINAL line must be exactly: continue or fail"
288287 echo " ::error::Build still fails after retry"
289288 cat >> " $REPORT_FILE " << BUILD_FAIL_EOF
290289
291- ### BUILD FAILED: $( git show --no-patch --format=reference HEAD )
290+ ### BUILD FAILED: $rebase_head_ref
292291
293292Build failed after conflict resolution. Last 50 lines:
294293
@@ -304,6 +303,7 @@ BUILD_FAIL_EOF
304303 echo " ::endgroup::"
305304 fi
306305 rm -f make.log
306+ GIT_EDITOR=: git rebase --continue || :
307307 ;;
308308 fail)
309309 echo " ::error::AI could not resolve conflict: $rebase_head_oneline "
@@ -341,10 +341,11 @@ EOF
341341# Function to run a rebase with AI-powered conflict resolution
342342# Usage: run_rebase_with_ai <rebase-args...>
343343run_rebase_with_ai () {
344- while true ; do
345- if git rebase " $@ " 2>&1 ; then
346- break
347- fi
344+ if git rebase " $@ " 2>&1 ; then
345+ return
346+ fi
347+
348+ while git rev-parse --verify REBASE_HEAD > /dev/null 2>&1 ; do
348349
349350 # Check if we have a conflict
350351 if ! git diff --name-only --diff-filter=U | grep -q . ; then
@@ -372,7 +373,7 @@ Detected via exact range-diff match (no AI needed).
372373
373374TRIVIAL_SKIP_EOF
374375 CONFLICTS_SKIPPED=$(( CONFLICTS_SKIPPED + 1 ))
375- git rebase --skip
376+ git rebase --skip || :
376377 continue
377378 fi
378379
@@ -397,7 +398,7 @@ Used resolution from: $(git show --no-patch --format=reference "$corresponding_o
397398
398399RESOLVED_EOF
399400 CONFLICTS_RESOLVED=$(( CONFLICTS_RESOLVED + 1 ))
400- GIT_EDITOR=: git rebase --continue
401+ GIT_EDITOR=: git rebase --continue || :
401402 continue 2
402403 fi
403404 done
@@ -484,6 +485,14 @@ if test "$BEHIND_COUNT" -gt 0; then
484485 fi
485486fi
486487
488+ # Check if there's anything to rebase after syncing
489+ UPSTREAM_AHEAD=$( git rev-list --count " $OLD_UPSTREAM ..$NEW_UPSTREAM " )
490+ if test " $UPSTREAM_AHEAD " -eq 0; then
491+ echo " ::notice::Nothing to rebase: upstream has no new commits since $OLD_UPSTREAM "
492+ echo " Current HEAD is at $( git rev-parse --short HEAD) "
493+ exit 0
494+ fi
495+
487496# Initialize report
488497cat > " $REPORT_FILE " << EOF
489498# Rebase Summary: ${SHEARS_BRANCH##*/ }
0 commit comments