(c *C, sto storage.Storer)
| 496 | } |
| 497 | |
| 498 | func (s *RemoteSuite) testFetchFastForward(c *C, sto storage.Storer) { |
| 499 | r := NewRemote(sto, &config.RemoteConfig{ |
| 500 | URLs: []string{s.GetBasicLocalRepositoryURL()}, |
| 501 | }) |
| 502 | |
| 503 | s.testFetch(c, r, &FetchOptions{ |
| 504 | RefSpecs: []config.RefSpec{ |
| 505 | config.RefSpec("+refs/heads/master:refs/heads/master"), |
| 506 | }, |
| 507 | }, []*plumbing.Reference{ |
| 508 | plumbing.NewReferenceFromStrings("refs/heads/master", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), |
| 509 | }) |
| 510 | |
| 511 | // First make sure that we error correctly when a force is required. |
| 512 | err := r.Fetch(&FetchOptions{ |
| 513 | RefSpecs: []config.RefSpec{ |
| 514 | config.RefSpec("refs/heads/branch:refs/heads/master"), |
| 515 | }, |
| 516 | }) |
| 517 | c.Assert(err, Equals, ErrForceNeeded) |
| 518 | |
| 519 | // And that forcing it fixes the problem. |
| 520 | err = r.Fetch(&FetchOptions{ |
| 521 | RefSpecs: []config.RefSpec{ |
| 522 | config.RefSpec("+refs/heads/branch:refs/heads/master"), |
| 523 | }, |
| 524 | }) |
| 525 | c.Assert(err, IsNil) |
| 526 | |
| 527 | // Now test that a fast-forward, non-force fetch works. |
| 528 | r.s.SetReference(plumbing.NewReferenceFromStrings( |
| 529 | "refs/heads/master", "918c48b83bd081e863dbe1b80f8998f058cd8294", |
| 530 | )) |
| 531 | s.testFetch(c, r, &FetchOptions{ |
| 532 | RefSpecs: []config.RefSpec{ |
| 533 | config.RefSpec("refs/heads/master:refs/heads/master"), |
| 534 | }, |
| 535 | }, []*plumbing.Reference{ |
| 536 | plumbing.NewReferenceFromStrings("refs/heads/master", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), |
| 537 | }) |
| 538 | } |
| 539 | |
| 540 | func (s *RemoteSuite) TestFetchFastForwardMem(c *C) { |
| 541 | s.testFetchFastForward(c, memory.NewStorage()) |
no test coverage detected