aboutsummaryrefslogtreecommitdiffstats
path: root/repository_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-04-17 14:22:57 +0200
committerGitHub <noreply@github.com>2018-04-17 14:22:57 +0200
commit60fd949ef638cf688029c5784a0a449f4c562bc7 (patch)
treec30d529a8ffc695d69523ac95eb0875074187464 /repository_test.go
parenteec77c36c26558e470a3d882fb6c0d457f92891f (diff)
parent75da83739f25f528bf242341d62e01b773329470 (diff)
downloadgo-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.go63
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)
+}