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

Function trackGitOperations

src/tools/shared/gitOperationTracking.ts:189–277  ·  view source on GitHub ↗
(
  command: string,
  exitCode: number,
  stdout?: string,
)

Source from the content-addressed store, hash-verified

187
188// Exported for testing purposes
189export function trackGitOperations(
190 command: string,
191 exitCode: number,
192 stdout?: string,
193): void {
194 const success = exitCode === 0
195 if (!success) {
196 return
197 }
198
199 if (GIT_COMMIT_RE.test(command)) {
200 logEvent('tengu_git_operation', {
201 operation:
202 'commit' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
203 })
204 if (command.match(/--amend\b/)) {
205 logEvent('tengu_git_operation', {
206 operation:
207 'commit_amend' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
208 })
209 }
210 getCommitCounter()?.add(1)
211 }
212 if (GIT_PUSH_RE.test(command)) {
213 logEvent('tengu_git_operation', {
214 operation:
215 'push' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
216 })
217 }
218 const prHit = GH_PR_ACTIONS.find(a => a.re.test(command))
219 if (prHit) {
220 logEvent('tengu_git_operation', {
221 operation:
222 prHit.op as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
223 })
224 }
225 if (prHit?.action === 'created') {
226 getPrCounter()?.add(1)
227 // Auto-link session to PR if we can extract PR URL from stdout
228 if (stdout) {
229 const prInfo = findPrInStdout(stdout)
230 if (prInfo) {
231 // Import is done dynamically to avoid circular dependency
232 void import('../../utils/sessionStorage.js').then(
233 ({ linkSessionToPR }) => {
234 void import('../../bootstrap/state.js').then(({ getSessionId }) => {
235 const sessionId = getSessionId()
236 if (sessionId) {
237 void linkSessionToPR(
238 sessionId as `${string}-${string}-${string}-${string}-${string}`,
239 prInfo.prNumber,
240 prInfo.prUrl,
241 prInfo.prRepository,
242 )
243 }
244 })
245 },
246 )

Callers 2

callFunction · 0.85
callFunction · 0.85

Calls 7

logEventFunction · 0.85
getCommitCounterFunction · 0.85
getPrCounterFunction · 0.85
findPrInStdoutFunction · 0.85
getSessionIdFunction · 0.85
linkSessionToPRFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected