MCPcopy Create free account
hub / github.com/actions/checkout / initializeCommandManager

Method initializeCommandManager

src/git-command-manager.ts:662–752  ·  view source on GitHub ↗
(
    workingDirectory: string,
    lfs: boolean,
    doSparseCheckout: boolean
  )

Source from the content-addressed store, hash-verified

660 }
661
662 private async initializeCommandManager(
663 workingDirectory: string,
664 lfs: boolean,
665 doSparseCheckout: boolean
666 ): Promise<void> {
667 this.workingDirectory = workingDirectory
668
669 // Git-lfs will try to pull down assets if any of the local/user/system setting exist.
670 // If the user didn't enable `LFS` in their pipeline definition, disable LFS fetch/checkout.
671 this.lfs = lfs
672 if (!this.lfs) {
673 this.gitEnv['GIT_LFS_SKIP_SMUDGE'] = '1'
674 }
675
676 this.gitPath = await io.which('git', true)
677
678 // Git version
679 core.debug('Getting git version')
680 this.gitVersion = new GitVersion()
681 let gitOutput = await this.execGit(['version'])
682 let stdout = gitOutput.stdout.trim()
683 if (!stdout.includes('\n')) {
684 const match = stdout.match(/\d+\.\d+(\.\d+)?/)
685 if (match) {
686 this.gitVersion = new GitVersion(match[0])
687 }
688 }
689 if (!this.gitVersion.isValid()) {
690 throw new Error('Unable to determine git version')
691 }
692
693 // Minimum git version
694 if (!this.gitVersion.checkMinimum(MinimumGitVersion)) {
695 throw new Error(
696 `Minimum required git version is ${MinimumGitVersion}. Your git ('${this.gitPath}') is ${this.gitVersion}`
697 )
698 }
699
700 if (this.lfs) {
701 // Git-lfs version
702 core.debug('Getting git-lfs version')
703 let gitLfsVersion = new GitVersion()
704 const gitLfsPath = await io.which('git-lfs', true)
705 gitOutput = await this.execGit(['lfs', 'version'])
706 stdout = gitOutput.stdout.trim()
707 if (!stdout.includes('\n')) {
708 const match = stdout.match(/\d+\.\d+(\.\d+)?/)
709 if (match) {
710 gitLfsVersion = new GitVersion(match[0])
711 }
712 }
713 if (!gitLfsVersion.isValid()) {
714 throw new Error('Unable to determine git-lfs version')
715 }
716
717 // Minimum git-lfs version
718 // Note:
719 // - Auth header not supported before 2.1

Callers 1

createCommandManagerMethod · 0.95

Calls 3

execGitMethod · 0.95
isValidMethod · 0.95
checkMinimumMethod · 0.95

Tested by

no test coverage detected