fix: use auth when fetching (same as with cloning) (#687)

Co-authored-by: Björn Brauer <[email protected]>

Co-authored-by: Björn Brauer <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Markus Wolf
2021-05-18 06:25:07 +00:00
committed by GitHub
co-authored by Björn Brauer mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent f571290b25
commit 38f6dfb49a
+10 -2
View File
@@ -291,9 +291,17 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) Executor {
}
// fetch latest changes
err = r.Fetch(&git.FetchOptions{
fetchOptions := git.FetchOptions{
RefSpecs: []config.RefSpec{"refs/*:refs/*", "HEAD:refs/heads/HEAD"},
})
}
if input.Token != "" {
fetchOptions.Auth = &http.BasicAuth{
Username: "token",
Password: input.Token,
}
}
err = r.Fetch(&fetchOptions)
if err != nil && !errors.Is(err, git.NoErrAlreadyUpToDate) {
return err
}