MCPcopy Index your code
hub / github.com/codeaashu/claude-code / parseRefFromCommand

Function parseRefFromCommand

src/tools/shared/gitOperationTracking.ts:113–125  ·  view source on GitHub ↗

* Extract target ref from `git merge ` / `git rebase ` command. * Skips flags and keywords — first non-flag argument is the ref.

(
  command: string,
  verb: string,
)

Source from the content-addressed store, hash-verified

111 * Skips flags and keywords — first non-flag argument is the ref.
112 */
113function parseRefFromCommand(
114 command: string,
115 verb: string,
116): string | undefined {
117 const after = command.split(gitCmdRe(verb))[1]
118 if (!after) return undefined
119 for (const t of after.trim().split(/\s+/)) {
120 if (/^[&|;><]/.test(t)) break
121 if (t.startsWith('-')) continue
122 return t
123 }
124 return undefined
125}
126
127/**
128 * Scan bash command + output for git operations worth surfacing in the

Callers 1

detectGitOperationFunction · 0.85

Calls 1

gitCmdReFunction · 0.85

Tested by

no test coverage detected