fix: use auth when fetching (same as with cloning) (#687)
Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se> Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
f571290b25
commit
38f6dfb49a
1 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue