diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-19 14:15:34 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-19 14:15:34 +0200 |
commit | d851b90f5e832fa1edeb0d408bd56ed6c1fd5e7a (patch) | |
tree | ab25942ff243173a27979bc357d6bc516dda65d1 /repository_test.go | |
parent | 95bfc7e1c1b7101f2cd605cda58c1fb43d501d35 (diff) | |
download | go-git-d851b90f5e832fa1edeb0d408bd56ed6c1fd5e7a.tar.gz |
repository: allow push from shallow repositories
Diffstat (limited to 'repository_test.go')
-rw-r--r-- | repository_test.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go index f622007..f31cd1d 100644 --- a/repository_test.go +++ b/repository_test.go @@ -20,6 +20,7 @@ import ( . "gopkg.in/check.v1" "gopkg.in/src-d/go-billy.v3/memfs" "gopkg.in/src-d/go-billy.v3/osfs" + "gopkg.in/src-d/go-billy.v3/util" ) type RepositorySuite struct { @@ -767,6 +768,50 @@ func (s *RepositorySuite) TestPushToEmptyRepository(c *C) { c.Assert(err, IsNil) } +func (s *RepositorySuite) TestPushDepth(c *C) { + dir, err := ioutil.TempDir("", "push-depth") + defer os.RemoveAll(dir) + + origin, err := PlainClone(c.MkDir(), true, &CloneOptions{ + URL: fixtures.Basic().One().DotGit().Root(), + }) + + c.Assert(err, IsNil) + fs := origin.Storer.(*filesystem.Storage).Filesystem() + + r, err := Clone(memory.NewStorage(), memfs.New(), &CloneOptions{ + URL: fs.Root(), + Depth: 1, + }) + c.Assert(err, IsNil) + + err = util.WriteFile(r.wt, "foo", nil, 0755) + c.Assert(err, IsNil) + + w, err := r.Worktree() + c.Assert(err, IsNil) + + _, err = w.Add("foo") + c.Assert(err, IsNil) + + hash, err := w.Commit("foo", &CommitOptions{ + Author: defaultSignature(), + Committer: defaultSignature(), + }) + c.Assert(err, IsNil) + + err = r.Push(&PushOptions{}) + c.Assert(err, IsNil) + + remote, err := origin.Head() + c.Assert(err, IsNil) + c.Assert(remote.Hash(), Equals, hash) + + local, err := r.Head() + c.Assert(err, IsNil) + c.Assert(local.Hash(), Equals, remote.Hash()) +} + func (s *RepositorySuite) TestPushNonExistentRemote(c *C) { srcFs := fixtures.Basic().One().DotGit() sto, err := filesystem.NewStorage(srcFs) |