diff options
author | Jeremy Stribling <strib@alum.mit.edu> | 2017-11-27 16:06:44 -0800 |
---|---|---|
committer | Jeremy Stribling <strib@alum.mit.edu> | 2017-11-27 16:09:04 -0800 |
commit | 129ff16f8686bb74a206cf58000de1d9640e370a (patch) | |
tree | 1d7d288bcebace34c0a787d6090323ab7e003f52 /storage | |
parent | c8ca7e3d031214b6c0478d62119dfb8a9af1631d (diff) | |
download | go-git-129ff16f8686bb74a206cf58000de1d9640e370a.tar.gz |
dotgit: add a test for removing a ref from a file and packed-refs
Diffstat (limited to 'storage')
-rw-r--r-- | storage/filesystem/internal/dotgit/dotgit_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit_test.go b/storage/filesystem/internal/dotgit/dotgit_test.go index 7d327c8..913622a 100644 --- a/storage/filesystem/internal/dotgit/dotgit_test.go +++ b/storage/filesystem/internal/dotgit/dotgit_test.go @@ -184,6 +184,35 @@ func (s *SuiteDotGit) TestRemoveRefFromPackedRefs(c *C) { "e8d3ffab552895c19b9fcf7aa264d277cde33881 refs/remotes/origin/branch\n") } +func (s *SuiteDotGit) TestRemoveRefFromReferenceFileAndPackedRefs(c *C) { + fs := fixtures.Basic().ByTag(".git").One().DotGit() + dir := New(fs) + + // Make a ref file for a ref that's already in `packed-refs`. + err := dir.SetRef(plumbing.NewReferenceFromStrings( + "refs/remotes/origin/branch", + "e8d3ffab552895c19b9fcf7aa264d277cde33881", + )) + + name := plumbing.ReferenceName("refs/remotes/origin/branch") + err = dir.RemoveRef(name) + c.Assert(err, IsNil) + + b, err := ioutil.ReadFile(filepath.Join(fs.Root(), packedRefsPath)) + c.Assert(err, IsNil) + + c.Assert(string(b), Equals, ""+ + "# pack-refs with: peeled fully-peeled \n"+ + "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 refs/heads/master\n"+ + "6ecf0ef2c2dffb796033e5a02219af86ec6584e5 refs/remotes/origin/master\n") + + refs, err := dir.Refs() + c.Assert(err, IsNil) + + ref := findReference(refs, string(name)) + c.Assert(ref, IsNil) +} + func (s *SuiteDotGit) TestRemoveRefNonExistent(c *C) { fs := fixtures.Basic().ByTag(".git").One().DotGit() dir := New(fs) |