Skip to content

Commit

Permalink
Merge pull request fluxcd#988 from weaveworks/helm-operator-non-maste…
Browse files Browse the repository at this point in the history
…r-clone-issue2

Fix for Helm operator non-master branch clone issue
  • Loading branch information
tamarakaufler authored Mar 8, 2018
2 parents bd0af49 + 0c37939 commit a82891f
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions integrations/helm/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ func (ch *Checkout) Clone(ctx context.Context, cloneSubdir string) error {
}
ch.Dir = repoDir

repo, err := gogit.PlainClone(repoDir, false, &gogit.CloneOptions{
URL: ch.Config.URL,
Auth: ch.auth,
repo, err := gogit.PlainCloneContext(ctx, repoDir, false, &gogit.CloneOptions{
URL: ch.Config.URL,
Auth: ch.auth,
ReferenceName: plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", ch.Config.Branch)),
})
if err != nil {
return err
Expand All @@ -110,14 +111,6 @@ func (ch *Checkout) Clone(ctx context.Context, cloneSubdir string) error {
return err
}

br := ch.Config.Branch
err = wt.Checkout(&gogit.CheckoutOptions{
Branch: plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", br)),
})
if err != nil {
return err
}

ch.Repo = repo
ch.worktree = wt

Expand Down Expand Up @@ -181,8 +174,9 @@ func (ch *Checkout) Pull(ctx context.Context) error {
return ErrNoRepoCloned
}
err := w.Pull(&gogit.PullOptions{
RemoteName: "origin",
Auth: ch.auth,
RemoteName: "origin",
Auth: ch.auth,
ReferenceName: plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", ch.Config.Branch)),
})
if err != nil && err != gogit.NoErrAlreadyUpToDate {
return err
Expand Down

0 comments on commit a82891f

Please sign in to comment.