Skip to content

Commit

Permalink
fix(git): add auth to fetch (#8664)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Goodness <[email protected]>
  • Loading branch information
mgoodness authored May 6, 2022
1 parent 70f7020 commit dd56520
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions workflow/artifacts/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,16 @@ func (g *ArtifactDriver) Load(inputArtifact *wfv1.Artifact, path string) error {
}

if a.Revision != "" {
refspecs := []config.RefSpec{"refs/heads/*:refs/heads/*"}
refSpecs := []config.RefSpec{"refs/heads/*:refs/heads/*"}
if a.SingleBranch {
refspecs = []config.RefSpec{config.RefSpec(fmt.Sprintf("refs/heads/%s:refs/heads/%s", a.Branch, a.Branch))}
refSpecs = []config.RefSpec{config.RefSpec(fmt.Sprintf("refs/heads/%s:refs/heads/%s", a.Branch, a.Branch))}
}
if err := r.Fetch(&git.FetchOptions{RefSpecs: refspecs}); isFetchErr(err) {
return fmt.Errorf("failed to fatch refs: %w", err)
opts := &git.FetchOptions{Auth: auth, RefSpecs: refSpecs}
if err := opts.Validate(); err != nil {
return fmt.Errorf("failed to validate fetch %v: %w", refSpecs, err)
}
if err := r.Fetch(opts); isFetchErr(err) {
return fmt.Errorf("failed to fetch %v: %w", refSpecs, err)
}
h, err := r.ResolveRevision(plumbing.Revision(a.Revision))
if err != nil {
Expand Down

0 comments on commit dd56520

Please sign in to comment.