Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Use the default branch when glide.yaml doesn’t specify
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynvs committed May 15, 2017
1 parent b4380e3 commit adc74e5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ func getProjectConstraint(arg string, sm gps.SourceManager) (gps.ProjectConstrai
arg = parts[0]
versionStr = parts[1]
}

// TODO: What if there is no @, assume default branch (which may not be master) ?
// When there is no `@`, use the default branch

// TODO: if we decide to keep equals.....

// split on colon if there is a network location
Expand All @@ -300,12 +300,27 @@ func getProjectConstraint(arg string, sm gps.SourceManager) (gps.ProjectConstrai
if err != nil {
return emptyPC, err
}
return gps.ProjectConstraint{Ident:pi, Constraint: c}, nil
return gps.ProjectConstraint{Ident: pi, Constraint: c}, nil
}

// deduceConstraint tries to puzzle out what kind of version is given in a string -
// semver, a revision, or as a fallback, a plain tag
func deduceConstraint(s string, pi gps.ProjectIdentifier, sm gps.SourceManager) (gps.Constraint, error) {
if s == "" {
// Find the default branch
// TODO (carolynvs): Should this be defined on SourceManager directly?
versions, err := sm.ListVersions(pi)
if err != nil {
return nil, errors.Wrapf(err, "list versions for %s(%s)", pi.ProjectRoot, pi.Source) // means repo does not exist
}

for _, v := range versions {
if v.Type() == gps.IsBranch {
return v.Unpair(), nil
}
}
}

// always semver if we can
c, err := gps.NewSemverConstraint(s)
if err == nil {
Expand Down

0 comments on commit adc74e5

Please sign in to comment.