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

Class GitCommandManager

src/git-command-manager.ts:97–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97class GitCommandManager {
98 private gitEnv = {
99 GIT_TERMINAL_PROMPT: '0', // Disable git prompt
100 GCM_INTERACTIVE: 'Never' // Disable prompting for git credential manager
101 }
102 private gitPath = ''
103 private lfs = false
104 private doSparseCheckout = false
105 private workingDirectory = ''
106 private gitVersion: GitVersion = new GitVersion()
107
108 // Private constructor; use createCommandManager()
109 private constructor() {}
110
111 async branchDelete(remote: boolean, branch: string): Promise<void> {
112 const args = ['branch', '--delete', '--force']
113 if (remote) {
114 args.push('--remote')
115 }
116 args.push(branch)
117
118 await this.execGit(args)
119 }
120
121 async branchExists(remote: boolean, pattern: string): Promise<boolean> {
122 const args = ['branch', '--list']
123 if (remote) {
124 args.push('--remote')
125 }
126 args.push(pattern)
127
128 const output = await this.execGit(args)
129 return !!output.stdout.trim()
130 }
131
132 async branchList(remote: boolean): Promise<string[]> {
133 const result: string[] = []
134
135 // Note, this implementation uses "rev-parse --symbolic-full-name" because the output from
136 // "branch --list" is more difficult when in a detached HEAD state.
137
138 // TODO(https://github.com/actions/checkout/issues/786): this implementation uses
139 // "rev-parse --symbolic-full-name" because there is a bug
140 // in Git 2.18 that causes "rev-parse --symbolic" to output symbolic full names. When
141 // 2.18 is no longer supported, we can switch back to --symbolic.
142
143 const args = ['rev-parse', '--symbolic-full-name']
144 if (remote) {
145 args.push('--remotes=origin')
146 } else {
147 args.push('--branches')
148 }
149
150 const stderr: string[] = []
151 const errline: string[] = []
152 const stdout: string[] = []
153 const stdline: string[] = []
154

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…