diff options
author | Santiago M. Mola <santi@mola.io> | 2017-04-27 14:35:21 +0200 |
---|---|---|
committer | Santiago M. Mola <santi@mola.io> | 2017-04-27 14:38:17 +0200 |
commit | 44ee22785a6debcef920381b2afd7f0ebdb4338e (patch) | |
tree | 1583a12dee23ddb6d973cb50df4d0bcd179e4249 /remote_test.go | |
parent | bc6b1c429f5a6f4d78a17cbe0e1a9927416f4f1b (diff) | |
download | go-git-44ee22785a6debcef920381b2afd7f0ebdb4338e.tar.gz |
add test for tags push, closes #354
Diffstat (limited to 'remote_test.go')
-rw-r--r-- | remote_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/remote_test.go b/remote_test.go index d48b6ca..3824d55 100644 --- a/remote_test.go +++ b/remote_test.go @@ -249,6 +249,51 @@ func (s *RemoteSuite) TestPushToEmptyRepository(c *C) { c.Assert(err, IsNil) } +func (s *RemoteSuite) TestPushTags(c *C) { + srcFs := fixtures.ByURL("https://github.com/git-fixtures/tags.git").One().DotGit() + sto, err := filesystem.NewStorage(srcFs) + c.Assert(err, IsNil) + + dstFs := fixtures.ByTag("empty").One().DotGit() + url := fmt.Sprintf("file://%s", dstFs.Base()) + + r := newRemote(sto, &config.RemoteConfig{ + Name: DefaultRemoteName, + URL: url, + }) + + rs := config.RefSpec("refs/tags/*:refs/tags/*") + err = r.Push(&PushOptions{ + RefSpecs: []config.RefSpec{rs}, + }) + c.Assert(err, IsNil) + + dstSto, err := filesystem.NewStorage(dstFs) + c.Assert(err, IsNil) + dstRepo, err := Open(dstSto, nil) + c.Assert(err, IsNil) + + ref, err := dstRepo.Storer.Reference(plumbing.ReferenceName("refs/tags/lightweight-tag")) + c.Assert(err, IsNil) + c.Assert(ref, DeepEquals, plumbing.NewReferenceFromStrings("refs/tags/lightweight-tag", "f7b877701fbf855b44c0a9e86f3fdce2c298b07f")) + + ref, err = dstRepo.Storer.Reference(plumbing.ReferenceName("refs/tags/annotated-tag")) + c.Assert(err, IsNil) + c.Assert(ref, DeepEquals, plumbing.NewReferenceFromStrings("refs/tags/annotated-tag", "b742a2a9fa0afcfa9a6fad080980fbc26b007c69")) + + ref, err = dstRepo.Storer.Reference(plumbing.ReferenceName("refs/tags/commit-tag")) + c.Assert(err, IsNil) + c.Assert(ref, DeepEquals, plumbing.NewReferenceFromStrings("refs/tags/commit-tag", "ad7897c0fb8e7d9a9ba41fa66072cf06095a6cfc")) + + ref, err = dstRepo.Storer.Reference(plumbing.ReferenceName("refs/tags/blob-tag")) + c.Assert(err, IsNil) + c.Assert(ref, DeepEquals, plumbing.NewReferenceFromStrings("refs/tags/blob-tag", "fe6cb94756faa81e5ed9240f9191b833db5f40ae")) + + ref, err = dstRepo.Storer.Reference(plumbing.ReferenceName("refs/tags/tree-tag")) + c.Assert(err, IsNil) + c.Assert(ref, DeepEquals, plumbing.NewReferenceFromStrings("refs/tags/tree-tag", "152175bf7e5580299fa1f0ba41ef6474cc043b70")) +} + func (s *RemoteSuite) TestPushNoErrAlreadyUpToDate(c *C) { f := fixtures.Basic().One() sto, err := filesystem.NewStorage(f.DotGit()) |