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
11 changes: 6 additions & 5 deletions util/git/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ func (m *NativeGitClient) CloneOrFetch(repo string, username string, password st
needClone = err != nil
}

repoURL, env, err := GetGitCommandEnvAndURL(repo, username, password, sshPrivateKey)
if err != nil {
return err
}

if needClone {
_, err := exec.Command("rm", "-rf", repoPath).Output()
if err != nil {
return fmt.Errorf("unable to clean repo cache at %s: %v", repoPath, err)
}

repoURL, env, err := GetGitCommandEnvAndURL(repo, username, password, sshPrivateKey)
if err != nil {
return err
}

log.Infof("Cloning %s to %s", repo, repoPath)
cmd := exec.Command("git", "clone", repoURL, repoPath)
cmd.Env = env
Expand All @@ -54,6 +54,7 @@ func (m *NativeGitClient) CloneOrFetch(repo string, username string, password st
log.Infof("Fetching %s", repo)
// Fetch remote changes and delete all local branches
cmd := exec.Command("sh", "-c", "git fetch --all && git checkout --detach HEAD")
cmd.Env = env
cmd.Dir = repoPath
_, err := cmd.Output()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion util/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func GetGitCommandEnvAndURL(repo, username, password string, sshPrivateKey strin
if err != nil {
return "", nil, err
}
env = append(env, fmt.Sprintf("GIT_SSH_COMMAND=ssh -i %s", sshFile.Name()))
env = append(env, fmt.Sprintf("GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no -i %s", sshFile.Name()))
}
} else {
env = append(env, "GIT_ASKPASS=")
Expand Down