* Scan a bash tool result for commit SHAs and PR URLs and push them into the * group accumulator. Called only for results whose tool_use_id was recorded * in bashCommands (non-search/read bash).
( msg: CollapsibleMessage, group: GroupAccumulator, )
| 553 | * in bashCommands (non-search/read bash). |
| 554 | */ |
| 555 | function scanBashResultForGitOps( |
| 556 | msg: CollapsibleMessage, |
| 557 | group: GroupAccumulator, |
| 558 | ): void { |
| 559 | if (msg.type !== 'user') return |
| 560 | const out = msg.toolUseResult as |
| 561 | | { stdout?: string; stderr?: string } |
| 562 | | undefined |
| 563 | if (!out?.stdout && !out?.stderr) return |
| 564 | // git push writes the ref update to stderr — scan both streams. |
| 565 | const combined = (out.stdout ?? '') + '\n' + (out.stderr ?? '') |
| 566 | for (const c of msg.message.content) { |
| 567 | if (c.type !== 'tool_result') continue |
| 568 | const command = group.bashCommands?.get(c.tool_use_id) |
| 569 | if (!command) continue |
| 570 | const { commit, push, branch, pr } = detectGitOperation(command, combined) |
| 571 | if (commit) group.commits?.push(commit) |
| 572 | if (push) group.pushes?.push(push) |
| 573 | if (branch) group.branches?.push(branch) |
| 574 | if (pr) group.prs?.push(pr) |
| 575 | if (commit || push || branch || pr) { |
| 576 | group.gitOpBashCount = (group.gitOpBashCount ?? 0) + 1 |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | type GroupAccumulator = { |
| 582 | messages: CollapsibleMessage[] |
no test coverage detected