Skip to content

Commit

Permalink
Simplified branch switching
Browse files Browse the repository at this point in the history
  • Loading branch information
coufalja committed May 10, 2018
1 parent d662934 commit 37f3b98
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions pkg/fetch/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/transport"
"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
"os"
"strings"
)

Expand Down Expand Up @@ -55,20 +54,6 @@ func (f *fetcher) Fetch() (*object.Commit, error) {
log.Infof("Repository found in '%s' opening...", f.directory)
}

if branch, err := r.Branch(f.branch); branch == nil || err != nil {
log.Infof("Branch switched to '%s'", f.branch)
os.RemoveAll(f.directory)
r, err = git.PlainClone(f.directory, false, &git.CloneOptions{
URL: f.url,
Auth: f.auth,
ReferenceName: plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", f.branch)),
})
if err != nil {
log.Errorf("Failed to switch branch to '%s': %v", f.branch, err)
return nil, err
}
}

log.Info("Fetching changes")
err = r.Fetch(&git.FetchOptions{
Auth: f.auth,
Expand Down

0 comments on commit 37f3b98

Please sign in to comment.