Skip to content

Commit

Permalink
Don't assume every git repository has a HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
BartSchuurmans authored and zknill committed Oct 6, 2017
1 parent 6e42c4a commit 0c15088
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/gps/vcs_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,18 @@ func (s *gitSource) listVersions(ctx context.Context) (vlist []PairedVersion, er
//
// If all of those conditions are met, then the user would end up with an
// erroneous non-default branch in their lock file.
headrev := Revision(all[0][:40])
var headrev Revision
var onedef, multidef, defmaster bool

smap := make(map[string]bool)
uniq := 0
vlist = make([]PairedVersion, len(all)-1) // less 1, because always ignore HEAD
vlist = make([]PairedVersion, len(all))
for _, pair := range all {
var v PairedVersion
if string(pair[46:51]) == "heads" {
if string(pair[41:]) == "HEAD" {
// If HEAD is present, it's always first
headrev = Revision(pair[:40])
} else if string(pair[46:51]) == "heads" {
rev := Revision(pair[:40])

isdef := rev == headrev
Expand Down

0 comments on commit 0c15088

Please sign in to comment.