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

Function gitPull

src/utils/plugins/marketplaceManager.ts:528–582  ·  view source on GitHub ↗
(
  cwd: string,
  ref?: string,
  options?: { disableCredentialHelper?: boolean; sparsePaths?: string[] },
)

Source from the content-addressed store, hash-verified

526}
527
528export async function gitPull(
529 cwd: string,
530 ref?: string,
531 options?: { disableCredentialHelper?: boolean; sparsePaths?: string[] },
532): Promise<{ code: number; stderr: string }> {
533 logForDebugging(`git pull: cwd=${cwd} ref=${ref ?? 'default'}`)
534 const env = { ...process.env, ...GIT_NO_PROMPT_ENV }
535 const credentialArgs = options?.disableCredentialHelper
536 ? ['-c', 'credential.helper=']
537 : []
538
539 if (ref) {
540 const fetchResult = await execFileNoThrowWithCwd(
541 gitExe(),
542 [...credentialArgs, 'fetch', 'origin', ref],
543 { cwd, timeout: getPluginGitTimeoutMs(), stdin: 'ignore', env },
544 )
545
546 if (fetchResult.code !== 0) {
547 return enhanceGitPullErrorMessages(fetchResult)
548 }
549
550 const checkoutResult = await execFileNoThrowWithCwd(
551 gitExe(),
552 [...credentialArgs, 'checkout', ref],
553 { cwd, timeout: getPluginGitTimeoutMs(), stdin: 'ignore', env },
554 )
555
556 if (checkoutResult.code !== 0) {
557 return enhanceGitPullErrorMessages(checkoutResult)
558 }
559
560 const pullResult = await execFileNoThrowWithCwd(
561 gitExe(),
562 [...credentialArgs, 'pull', 'origin', ref],
563 { cwd, timeout: getPluginGitTimeoutMs(), stdin: 'ignore', env },
564 )
565 if (pullResult.code !== 0) {
566 return enhanceGitPullErrorMessages(pullResult)
567 }
568 await gitSubmoduleUpdate(cwd, credentialArgs, env, options?.sparsePaths)
569 return pullResult
570 }
571
572 const result = await execFileNoThrowWithCwd(
573 gitExe(),
574 [...credentialArgs, 'pull', 'origin', 'HEAD'],
575 { cwd, timeout: getPluginGitTimeoutMs(), stdin: 'ignore', env },
576 )
577 if (result.code !== 0) {
578 return enhanceGitPullErrorMessages(result)
579 }
580 await gitSubmoduleUpdate(cwd, credentialArgs, env, options?.sparsePaths)
581 return result
582}
583
584/**
585 * Sync submodule working dirs after a successful pull. gitClone() uses

Callers 1

cacheMarketplaceFromGitFunction · 0.85

Calls 5

logForDebuggingFunction · 0.85
execFileNoThrowWithCwdFunction · 0.85
getPluginGitTimeoutMsFunction · 0.85
gitSubmoduleUpdateFunction · 0.85

Tested by

no test coverage detected