aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMike Lundy <mike@fluffypenguin.org>2019-05-14 16:13:55 -0700
committerMike Lundy <mike@fluffypenguin.org>2019-05-14 16:41:32 -0700
commit33f05f3773e1c1e6b4fdde5ee984f6b1935afbfc (patch)
treedbbf58de086de41ce326264585964bb774aa36d0 /repository_test.go
parent52fcf7d8a3c2da58769e105a26240e3e697fedeb (diff)
downloadgo-git-33f05f3773e1c1e6b4fdde5ee984f6b1935afbfc.tar.gz
improve ResolveRevision's Ref lookup path
1) lookups on an annotated tag oid now work 2) there was a lot of complexity around detection of ambiguity, but unlike git, ambiguous refs are rejected (which causes bugs like #823). The new code matches rev-parse's behavior (prefer the OID), though there is no warning path to report the same warning. Signed-off-by: Mike Lundy <mike@fluffypenguin.org>
Diffstat (limited to 'repository_test.go')
-rw-r--r--repository_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/repository_test.go b/repository_test.go
index ccbe29b..0148c78 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -2415,7 +2415,7 @@ func (s *RepositorySuite) TestResolveRevision(c *C) {
for rev, hash := range datas {
h, err := r.ResolveRevision(plumbing.Revision(rev))
- c.Assert(err, IsNil)
+ c.Assert(err, IsNil, Commentf("while checking %s", rev))
c.Check(h.String(), Equals, hash, Commentf("while checking %s", rev))
}
}
@@ -2427,13 +2427,14 @@ func (s *RepositorySuite) TestResolveRevisionAnnotated(c *C) {
c.Assert(err, IsNil)
datas := map[string]string{
- "refs/tags/annotated-tag": "f7b877701fbf855b44c0a9e86f3fdce2c298b07f",
+ "refs/tags/annotated-tag": "f7b877701fbf855b44c0a9e86f3fdce2c298b07f",
+ "b742a2a9fa0afcfa9a6fad080980fbc26b007c69": "f7b877701fbf855b44c0a9e86f3fdce2c298b07f",
}
for rev, hash := range datas {
h, err := r.ResolveRevision(plumbing.Revision(rev))
- c.Assert(err, IsNil)
+ c.Assert(err, IsNil, Commentf("while checking %s", rev))
c.Check(h.String(), Equals, hash, Commentf("while checking %s", rev))
}
}
@@ -2459,12 +2460,11 @@ func (s *RepositorySuite) TestResolveRevisionWithErrors(c *C) {
"HEAD^3": `Revision invalid : "3" found must be 0, 1 or 2 after "^"`,
"HEAD^{/whatever}": `No commit message match regexp : "whatever"`,
"4e1243bd22c66e76c2ba9eddc1f91394e57f9f83": "reference not found",
- "918c48b83bd081e863dbe1b80f8998f058cd8294": `refname "918c48b83bd081e863dbe1b80f8998f058cd8294" is ambiguous`,
}
for rev, rerr := range datas {
_, err := r.ResolveRevision(plumbing.Revision(rev))
-
+ c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, rerr)
}
}