diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2018-04-17 14:22:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 14:22:57 +0200 |
commit | 60fd949ef638cf688029c5784a0a449f4c562bc7 (patch) | |
tree | c30d529a8ffc695d69523ac95eb0875074187464 /repository_test.go | |
parent | eec77c36c26558e470a3d882fb6c0d457f92891f (diff) | |
parent | 75da83739f25f528bf242341d62e01b773329470 (diff) | |
download | go-git-60fd949ef638cf688029c5784a0a449f4c562bc7.tar.gz |
Merge pull request #810 from jfontan/fix/update-shallow
git: remote, Add shallow commits instead of substituting. Fixes #412
Diffstat (limited to 'repository_test.go')
-rw-r--r-- | repository_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go index c98e2ac..be7f163 100644 --- a/repository_test.go +++ b/repository_test.go @@ -1615,3 +1615,66 @@ func executeOnPath(path, cmd string) error { return c.Run() } + +func (s *RepositorySuite) TestBrokenMultipleShallowFetch(c *C) { + r, _ := Init(memory.NewStorage(), nil) + _, err := r.CreateRemote(&config.RemoteConfig{ + Name: DefaultRemoteName, + URLs: []string{s.GetBasicLocalRepositoryURL()}, + }) + c.Assert(err, IsNil) + + c.Assert(r.Fetch(&FetchOptions{ + Depth: 2, + RefSpecs: []config.RefSpec{config.RefSpec("refs/heads/master:refs/heads/master")}, + }), IsNil) + + shallows, err := r.Storer.Shallow() + c.Assert(err, IsNil) + c.Assert(len(shallows), Equals, 1) + + ref, err := r.Reference("refs/heads/master", true) + c.Assert(err, IsNil) + cobj, err := r.CommitObject(ref.Hash()) + c.Assert(err, IsNil) + c.Assert(cobj, NotNil) + err = object.NewCommitPreorderIter(cobj, nil, nil).ForEach(func(c *object.Commit) error { + for _, ph := range c.ParentHashes { + for _, h := range shallows { + if ph == h { + return storer.ErrStop + } + } + } + + return nil + }) + c.Assert(err, IsNil) + + c.Assert(r.Fetch(&FetchOptions{ + Depth: 5, + RefSpecs: []config.RefSpec{config.RefSpec("refs/heads/*:refs/heads/*")}, + }), IsNil) + + shallows, err = r.Storer.Shallow() + c.Assert(err, IsNil) + c.Assert(len(shallows), Equals, 3) + + ref, err = r.Reference("refs/heads/master", true) + c.Assert(err, IsNil) + cobj, err = r.CommitObject(ref.Hash()) + c.Assert(err, IsNil) + c.Assert(cobj, NotNil) + err = object.NewCommitPreorderIter(cobj, nil, nil).ForEach(func(c *object.Commit) error { + for _, ph := range c.ParentHashes { + for _, h := range shallows { + if ph == h { + return storer.ErrStop + } + } + } + + return nil + }) + c.Assert(err, IsNil) +} |