Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glide install skips fetch when it is up to date #494

Merged
merged 1 commit into from
Jun 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions repo/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func (i *Installer) Install(lock *cfg.Lockfile, conf *cfg.Config) (*cfg.Config,

msg.Info("Downloading dependencies. Please wait...")

ConcurrentUpdate(newConf.Imports, cwd, i, newConf)
ConcurrentUpdate(newConf.DevImports, cwd, i, newConf)
LazyConcurrentUpdate(newConf.Imports, cwd, i, newConf)
LazyConcurrentUpdate(newConf.DevImports, cwd, i, newConf)
return newConf, nil
}

Expand Down Expand Up @@ -302,6 +302,43 @@ func (i *Installer) List(conf *cfg.Config) []*cfg.Dependency {
return conf.Imports
}

// LazyConcurrentUpdate updates only deps that are not already checkout out at the right version.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, saw this too late - s/checkout out/checked out/

//
// This is only safe when updating from a lock file.
func LazyConcurrentUpdate(deps []*cfg.Dependency, cwd string, i *Installer, c *cfg.Config) error {

newDeps := []*cfg.Dependency{}
for _, dep := range deps {
destPath := filepath.Join(i.VendorPath(), dep.Name)

// Get a VCS object for this directory
repo, err := dep.GetRepo(destPath)
if err != nil {
newDeps = append(newDeps, dep)
continue
}

ver, err := repo.Version()
if err != nil {
newDeps = append(newDeps, dep)
continue
}

if ver == dep.Reference {
msg.Info("--> Found desired version %s %s!", dep.Name, dep.Reference)
continue
}

msg.Debug("--> Queue %s for update (%s != %s).", dep.Name, ver, dep.Reference)
newDeps = append(newDeps, dep)
}
if len(newDeps) > 0 {
return ConcurrentUpdate(newDeps, cwd, i, c)
}

return nil
}

// ConcurrentUpdate takes a list of dependencies and updates in parallel.
func ConcurrentUpdate(deps []*cfg.Dependency, cwd string, i *Installer, c *cfg.Config) error {
done := make(chan struct{}, concurrentWorkers)
Expand Down
4 changes: 2 additions & 2 deletions repo/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,14 @@ func VcsVersion(dep *cfg.Dependency, vend string) error {
}

ver := dep.Reference
// Referenes in Git can begin with a ^ which is similar to semver.
// References in Git can begin with a ^ which is similar to semver.
// If there is a ^ prefix we assume it's a semver constraint rather than
// part of the git/VCS commit id.
if repo.IsReference(ver) && !strings.HasPrefix(ver, "^") {
msg.Info("--> Setting version for %s to %s.\n", dep.Name, ver)
} else {

// Create the constraing first to make sure it's valid before
// Create the constraint first to make sure it's valid before
// working on the repo.
constraint, err := semver.NewConstraint(ver)

Expand Down