Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions service/runway/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ go_library(
"//platform/extension/consumergate/noop:go_default_library",
"//platform/extension/messagequeue:go_default_library",
"//platform/extension/messagequeue/mysql:go_default_library",
"//platform/git/exec:go_default_library",
"//runway/controller:go_default_library",
"//runway/controller/dlq:go_default_library",
"//runway/controller/merge:go_default_library",
Expand Down
38 changes: 15 additions & 23 deletions service/runway/server/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"go.uber.org/zap"

gitexec "github.com/uber/submitqueue/platform/git/exec"
gitmerger "github.com/uber/submitqueue/runway/extension/merger/git"
)

Expand Down Expand Up @@ -190,8 +191,9 @@ func setLocalConfig(checkoutPath, key, value string) error {
}

// runGit invokes the pinned git in dir with an environment scrubbed of ambient
// configuration but retaining what is needed to reach a remote — the same split
// the merger draws, so provisioning and merging authenticate identically.
// configuration but retaining what is needed to reach a remote. It composes that
// environment through gitexec.Env, the same source the merger uses, so
// provisioning and merging authenticate — and behave — identically.
func runGit(ctx context.Context, runtime gitmerger.GitRuntime, dir string, args ...string) ([]byte, error) {
full := append([]string{
"--exec-path=" + runtime.ExecPath,
Expand All @@ -200,27 +202,17 @@ func runGit(ctx context.Context, runtime gitmerger.GitRuntime, dir string, args

cmd := exec.CommandContext(ctx, runtime.Executable, full...)
cmd.Dir = dir
cmd.Env = []string{
"HOME=" + filepath.Join(dir, ".submitqueue-git-home"),
"GIT_CONFIG_NOSYSTEM=1",
"GIT_CONFIG_GLOBAL=" + os.DevNull,
"GIT_TERMINAL_PROMPT=0",
"GIT_EXEC_PATH=" + runtime.ExecPath,
"GIT_TEMPLATE_DIR=" + runtime.TemplateDir,
"LC_ALL=C",
"LANG=C",
}
for _, name := range []string{
"PATH", "SSH_AUTH_SOCK", "SSH_AGENT_PID",
"GIT_SSH", "GIT_SSH_COMMAND", "GIT_SSH_VARIANT",
"GIT_SSL_CAINFO", "GIT_SSL_CAPATH", "SSL_CERT_DIR", "SSL_CERT_FILE",
"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY",
"http_proxy", "https_proxy", "no_proxy",
} {
if v, ok := os.LookupEnv(name); ok {
cmd.Env = append(cmd.Env, name+"="+v)
}
}
cmd.Env = gitexec.Env(gitexec.EnvOptions{
Comment thread
behinddwalls marked this conversation as resolved.
Transport: true,
Passthrough: runtime.PassthroughEnv,
Literal: []string{
"HOME=" + filepath.Join(dir, ".submitqueue-git-home"),
"GIT_EXEC_PATH=" + runtime.ExecPath,
"GIT_TEMPLATE_DIR=" + runtime.TemplateDir,
"LC_ALL=C",
"LANG=C",
},
})

var stdout, stderr bytes.Buffer
cmd.Stdout = &stdout
Expand Down
Loading