diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2020-07-16 21:28:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-16 21:28:40 +0200 |
commit | 7906922c319b6077e8e66b70711073fb59a08a20 (patch) | |
tree | 5785565db48069ff8f173b9dddcbb1b4c1f7e8ff /storage/filesystem/object_test.go | |
parent | 41758ec4b81c557092d7566c3eed46f89c1ec3cc (diff) | |
parent | e28d9c90aad624596d20d1a59c8371d81b69190b (diff) | |
download | go-git-7906922c319b6077e8e66b70711073fb59a08a20.tar.gz |
Merge pull request #136 from dsymonds/revparse-partial-hash
Repository.ResolveRevision, support partial hashes
Diffstat (limited to 'storage/filesystem/object_test.go')
-rw-r--r-- | storage/filesystem/object_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go index 2d6f568..036420f 100644 --- a/storage/filesystem/object_test.go +++ b/storage/filesystem/object_test.go @@ -1,6 +1,7 @@ package filesystem import ( + "encoding/hex" "fmt" "io" "io/ioutil" @@ -332,6 +333,22 @@ func (s *FsSuite) TestGetFromObjectFileSharedCache(c *C) { c.Assert(err, Equals, plumbing.ErrObjectNotFound) } +func (s *FsSuite) TestHashesWithPrefix(c *C) { + // Same setup as TestGetFromObjectFile. + fs := fixtures.ByTag(".git").ByTag("unpacked").One().DotGit() + o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault()) + expected := plumbing.NewHash("f3dfe29d268303fc6e1bbce268605fc99573406e") + obj, err := o.EncodedObject(plumbing.AnyObject, expected) + c.Assert(err, IsNil) + c.Assert(obj.Hash(), Equals, expected) + + prefix, _ := hex.DecodeString("f3dfe2") + hashes, err := o.HashesWithPrefix(prefix) + c.Assert(err, IsNil) + c.Assert(hashes, HasLen, 1) + c.Assert(hashes[0].String(), Equals, "f3dfe29d268303fc6e1bbce268605fc99573406e") +} + func BenchmarkPackfileIter(b *testing.B) { defer fixtures.Clean() |