Skip to content
This repository has been archived by the owner on Feb 3, 2018. It is now read-only.

Commit

Permalink
Include tip in hg result set
Browse files Browse the repository at this point in the history
Helps with golang/dep#170
  • Loading branch information
sdboyer committed Apr 29, 2017
1 parent da7569e commit 7ea769b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 9 additions & 7 deletions vcs_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,20 +405,22 @@ func (s *hgSource) listVersions(ctx context.Context) ([]PairedVersion, error) {
continue
}

// tip is magic, don't include it
if bytes.HasPrefix(line, []byte("tip")) {
continue
}

// Split on colon; this gets us the rev and the tag plus local revno
pair := bytes.Split(line, []byte(":"))
if bytes.Equal(nulrev, pair[1]) {
// null rev indicates this tag is marked for deletion
continue
}

idx := bytes.IndexByte(pair[0], 32) // space
v := NewVersion(string(pair[0][:idx])).Is(Revision(pair[1])).(PairedVersion)
// tip moves like a branch, so treat it that way
var v PairedVersion
if bytes.HasPrefix(line, []byte("tip")) {
v = NewBranch("tip").Is(Revision(pair[1])).(PairedVersion)
} else {
idx := bytes.IndexByte(pair[0], 32) // space
v = NewVersion(string(pair[0][:idx])).Is(Revision(pair[1])).(PairedVersion)
}

vlist = append(vlist, v)
}

Expand Down
2 changes: 2 additions & 0 deletions vcs_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ func testHgSourceInteractions(t *testing.T) {
NewBranch("another").Is(Revision("b10d05d581e5401f383e48ccfeb84b48fde99d06")),
NewBranch("default").Is(Revision("3d466f437f6616da594bbab6446cc1cb4328d1bb")),
NewBranch("newbranch").Is(Revision("5e2a01be9aee942098e44590ae545c7143da9675")),
NewBranch("tip").Is(Revision("5e2a01be9aee942098e44590ae545c7143da9675")),
})
close(donech)
}()
Expand All @@ -500,6 +501,7 @@ func testHgSourceInteractions(t *testing.T) {
newDefaultBranch("default").Is(Revision("3d466f437f6616da594bbab6446cc1cb4328d1bb")),
NewBranch("another").Is(Revision("b10d05d581e5401f383e48ccfeb84b48fde99d06")),
NewBranch("newbranch").Is(Revision("5e2a01be9aee942098e44590ae545c7143da9675")),
NewBranch("tip").Is(Revision("5e2a01be9aee942098e44590ae545c7143da9675")),
})

<-donech
Expand Down

0 comments on commit 7ea769b

Please sign in to comment.