Skip to content

Commit

Permalink
Adding fastpath update back to Glide
Browse files Browse the repository at this point in the history
Fastpath updates skip pulling updates if the the current set version
is the version already checked out. For pinned updates or those
set to a tag this will make updates faster because for DVCS cases
glide doesn't need to go out to the Internet. Note, when branches
are set at the Reference updates still occur.
  • Loading branch information
mattfarina committed Sep 30, 2015
1 parent 3ab3eb8 commit 1ec3886
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cmd/get_imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,29 @@ func VcsUpdate(dep *Dependency, vend string, force bool) error {
} else if err != nil {
return err
} else {
// Check if the current version is a tag or commit id. If it is
// and that version is already checked out we can skip updating
// which is faster than going out to the Internet to perform
// an update.
if dep.Reference != "" {
version, err := repo.Version()
if err != nil {
return err
}
ib, err := isBranch(dep.Reference, repo)
if err != nil {
return err
}

// If the current version equals the ref and it's not a
// branch it's a tag or commit id so we can skip
// performing an update.
if version == dep.Reference && !ib {
Info("%s is already set to version %s. Skipping update.", dep.Name, dep.Reference)
return nil
}
}

if err := repo.Update(); err != nil {
Warn("Download failed.\n")
return err
Expand Down
13 changes: 13 additions & 0 deletions cmd/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ func getAllVcsRefs(repo vcs.Repo) ([]string, error) {
return refs, nil
}

func isBranch(branch string, repo vcs.Repo) (bool, error) {
branches, err := repo.Branches()
if err != nil {
return false, err
}
for _, b := range branches {
if b == branch {
return true, nil
}
}
return false, nil
}

// From the refs find all of the ones fitting the SemVer pattern.
// func findSemVerRefs(refs []string) ([]string, error) {
//
Expand Down

0 comments on commit 1ec3886

Please sign in to comment.