MCPcopy Create free account
hub / github.com/Noumena-Network/code / scanBashResultForGitOps

Function scanBashResultForGitOps

src/utils/collapseReadSearch.ts:584–608  ·  view source on GitHub ↗

* 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,
)

Source from the content-addressed store, hash-verified

582 * in bashCommands (non-search/read bash).
583 */
584function scanBashResultForGitOps(
585 msg: CollapsibleMessage,
586 group: GroupAccumulator,
587): void {
588 if (msg.type !== 'user') return
589 const out = msg.toolUseResult as
590 | { stdout?: string; stderr?: string }
591 | undefined
592 if (!out?.stdout && !out?.stderr) return
593 // git push writes the ref update to stderr — scan both streams.
594 const combined = (out.stdout ?? '') + '\n' + (out.stderr ?? '')
595 for (const c of msg.message.content) {
596 if (c.type !== 'tool_result') continue
597 const command = group.bashCommands?.get(c.tool_use_id)
598 if (!command) continue
599 const { commit, push, branch, pr } = detectGitOperation(command, combined)
600 if (commit) group.commits?.push(commit)
601 if (push) group.pushes?.push(push)
602 if (branch) group.branches?.push(branch)
603 if (pr) group.prs?.push(pr)
604 if (commit || push || branch || pr) {
605 group.gitOpBashCount = (group.gitOpBashCount ?? 0) + 1
606 }
607 }
608}
609
610type GroupAccumulator = {
611 messages: CollapsibleMessage[]

Callers 1

collapseReadSearchGroupsFunction · 0.85

Calls 2

detectGitOperationFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected