Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable strict host key checking while cloning repo in repo-server #45

Merged
merged 2 commits into from
Mar 20, 2018
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