MCPcopy
hub / github.com/go-git/go-git / TestBrokenMultipleShallowFetch

Method TestBrokenMultipleShallowFetch

repository_test.go:3304–3365  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

3302}
3303
3304func (s *RepositorySuite) TestBrokenMultipleShallowFetch(c *C) {
3305 r, _ := Init(memory.NewStorage(), nil)
3306 _, err := r.CreateRemote(&config.RemoteConfig{
3307 Name: DefaultRemoteName,
3308 URLs: []string{s.GetBasicLocalRepositoryURL()},
3309 })
3310 c.Assert(err, IsNil)
3311
3312 c.Assert(r.Fetch(&FetchOptions{
3313 Depth: 2,
3314 RefSpecs: []config.RefSpec{config.RefSpec("refs/heads/master:refs/heads/master")},
3315 }), IsNil)
3316
3317 shallows, err := r.Storer.Shallow()
3318 c.Assert(err, IsNil)
3319 c.Assert(len(shallows), Equals, 1)
3320
3321 ref, err := r.Reference("refs/heads/master", true)
3322 c.Assert(err, IsNil)
3323 cobj, err := r.CommitObject(ref.Hash())
3324 c.Assert(err, IsNil)
3325 c.Assert(cobj, NotNil)
3326 err = object.NewCommitPreorderIter(cobj, nil, nil).ForEach(func(c *object.Commit) error {
3327 for _, ph := range c.ParentHashes {
3328 for _, h := range shallows {
3329 if ph == h {
3330 return storer.ErrStop
3331 }
3332 }
3333 }
3334
3335 return nil
3336 })
3337 c.Assert(err, IsNil)
3338
3339 c.Assert(r.Fetch(&FetchOptions{
3340 Depth: 5,
3341 RefSpecs: []config.RefSpec{config.RefSpec("refs/heads/*:refs/heads/*")},
3342 }), IsNil)
3343
3344 shallows, err = r.Storer.Shallow()
3345 c.Assert(err, IsNil)
3346 c.Assert(len(shallows), Equals, 3)
3347
3348 ref, err = r.Reference("refs/heads/master", true)
3349 c.Assert(err, IsNil)
3350 cobj, err = r.CommitObject(ref.Hash())
3351 c.Assert(err, IsNil)
3352 c.Assert(cobj, NotNil)
3353 err = object.NewCommitPreorderIter(cobj, nil, nil).ForEach(func(c *object.Commit) error {
3354 for _, ph := range c.ParentHashes {
3355 for _, h := range shallows {
3356 if ph == h {
3357 return storer.ErrStop
3358 }
3359 }
3360 }
3361

Callers

nothing calls this directly

Calls 12

NewStorageFunction · 0.92
RefSpecTypeAlias · 0.92
NewCommitPreorderIterFunction · 0.92
InitFunction · 0.85
CreateRemoteMethod · 0.80
CommitObjectMethod · 0.80
ShallowMethod · 0.65
ReferenceMethod · 0.65
HashMethod · 0.65
ForEachMethod · 0.65
FetchMethod · 0.45

Tested by

no test coverage detected