MCPcopy Create free account
hub / github.com/cli/cli / gitEnvironment

Function gitEnvironment

script/ghmock/gitcmd.go:316–339  ·  view source on GitHub ↗
(env []string, scratch, world string)

Source from the content-addressed store, hash-verified

314}
315
316func gitEnvironment(env []string, scratch, world string) ([]string, error) {
317 exe, err := os.Executable()
318 if err != nil {
319 return nil, err
320 }
321 world, err = filepath.Abs(world)
322 if err != nil {
323 return nil, err
324 }
325 // Relocated Git distributions use this to find their transport helpers.
326 // It selects the installed tooling, not the caller's Git configuration.
327 if execPath := os.Getenv("GIT_EXEC_PATH"); execPath != "" {
328 env = append(env, "GIT_EXEC_PATH="+execPath)
329 }
330 return append(env,
331 "LC_ALL=C",
332 "GIT_AUTHOR_NAME=monalisa", "GIT_AUTHOR_EMAIL=monalisa@example.invalid",
333 "GIT_COMMITTER_NAME=monalisa", "GIT_COMMITTER_EMAIL=monalisa@example.invalid",
334 "GIT_AUTHOR_DATE=2000-01-01T00:00:00Z", "GIT_COMMITTER_DATE=2000-01-01T00:00:00Z",
335 "GIT_TEMPLATE_DIR="+filepath.Join(scratch, "templates"),
336 "GIT_SSH_COMMAND="+shellQuote(exe)+" _git-ssh", "GIT_SSH_VARIANT=ssh",
337 "GHMOCK_GIT_WORLD="+world, "GHMOCK_GIT_LOG="+filepath.Join(scratch, "git-ssh.jsonl"),
338 ), nil
339}
340
341func gitDeadlineEnvironment(ctx context.Context, env []string) []string {
342 if deadline, ok := ctx.Deadline(); ok {

Callers 4

serveGitHTTPMethod · 0.85
runBinaryFunction · 0.85
cmdRepoFunction · 0.85
cmdGitFunction · 0.85

Calls 3

JoinMethod · 0.80
shellQuoteFunction · 0.70
ExecutableMethod · 0.65

Tested by

no test coverage detected