Skip to content

Commit fc4fd5b

Browse files
authored
rebase-branch: recognize space-aligned Copilot stats trailer (#163)
The [scheduled `rebase-shears` run](https://github.com/git-for-windows/git-for-windows-automation/actions/runs/24401147325/job/71271793472) failed today with: ``` ##[error]Unexpected AI decision '': 6c02c9d442 tests: use the correct path separator with BusyBox ##[error]Rebase failed for shears/seen ``` The AI (Copilot CLI with `claude-opus-4.6`) actually resolved the `t/test-lib.sh` conflict correctly and output a valid decision: ``` continue -- kept both HEAD's `set -e` and REBASE_HEAD's `PATH_SEP` block as independent additions ``` But the `sed` state machine that extracts this decision from the Copilot output returned empty. The parser validates that everything after the decision line is blank lines and stats-like trailer lines before accepting it. The trailer the Copilot CLI actually emits looks like this: ``` Changes +1 -3 Requests 3 Premium (38s) Tokens 127.5k ↓ 1.5k 53.9k (cached) ``` These are space-aligned (word followed by 2+ spaces then value), but the `sed` script only recognized `key: value` lines (colon-separated). The stats lines were rejected, causing `sed` to discard the held decision and return nothing. The fix adds a second pattern in the `:stats` section that matches lines starting with an alphabetic word followed by two or more spaces, alongside the existing colon-based recognizer.
2 parents 7351be3 + be1952e commit fc4fd5b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

rebase-branch.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,9 @@ Your FINAL line must be exactly: skip <oid>, skip -- <reason>, continue -- <summ
254254
echo "::endgroup::"
255255

256256
# Extract the decision from the last meaningful line.
257-
# Copilot appends a stats trailer (key: value lines) after the actual
258-
# output, separated by blank lines. The sed script finds the last
257+
# Copilot appends a stats trailer after the actual output, separated
258+
# by blank lines. The format may be "key: value" (colon-separated)
259+
# or "Key value" (space-aligned). The sed script finds the last
259260
# decision keyword (continue/skip/fail) that is followed only by
260261
# blank lines and stats-like lines until EOF.
261262
decision=$(echo "$ai_output" | sed -n '
@@ -276,7 +277,10 @@ Your FINAL line must be exactly: skip <oid>, skip -- <reason>, continue -- <summ
276277
/^$/b emptyloop
277278
:stats
278279
/[A-Za-z][^:]\{0,30\}:$/{ n; /^ /!b; :ind; ${ g; p; q }; n; /^ /b ind; b stats }
279-
/^[^:]\{1,30\}: /!b
280+
/^[^:]\{1,30\}: /b stats_line
281+
/^[A-Za-z][A-Za-z]* /b stats_line
282+
b
283+
:stats_line
280284
${ g; p; q }
281285
n
282286
b stats

0 commit comments

Comments
 (0)