(c *C, sto storage.Storer)
| 463 | } |
| 464 | |
| 465 | func (s *RemoteSuite) testFetchFastForward(c *C, sto storage.Storer) { |
| 466 | r := NewRemote(sto, &config.RemoteConfig{ |
| 467 | URLs: []string{s.GetBasicLocalRepositoryURL()}, |
| 468 | }) |
| 469 | |
| 470 | s.testFetch(c, r, &FetchOptions{ |
| 471 | RefSpecs: []config.RefSpec{ |
| 472 | config.RefSpec("+refs/heads/master:refs/heads/master"), |
| 473 | }, |
| 474 | }, []*plumbing.Reference{ |
| 475 | plumbing.NewReferenceFromStrings("refs/heads/master", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), |
| 476 | }) |
| 477 | |
| 478 | // First make sure that we error correctly when a force is required. |
| 479 | err := r.Fetch(&FetchOptions{ |
| 480 | RefSpecs: []config.RefSpec{ |
| 481 | config.RefSpec("refs/heads/branch:refs/heads/master"), |
| 482 | }, |
| 483 | }) |
| 484 | c.Assert(err, Equals, ErrForceNeeded) |
| 485 | |
| 486 | // And that forcing it fixes the problem. |
| 487 | err = r.Fetch(&FetchOptions{ |
| 488 | RefSpecs: []config.RefSpec{ |
| 489 | config.RefSpec("+refs/heads/branch:refs/heads/master"), |
| 490 | }, |
| 491 | }) |
| 492 | c.Assert(err, IsNil) |
| 493 | |
| 494 | // Now test that a fast-forward, non-force fetch works. |
| 495 | r.s.SetReference(plumbing.NewReferenceFromStrings( |
| 496 | "refs/heads/master", "918c48b83bd081e863dbe1b80f8998f058cd8294", |
| 497 | )) |
| 498 | s.testFetch(c, r, &FetchOptions{ |
| 499 | RefSpecs: []config.RefSpec{ |
| 500 | config.RefSpec("refs/heads/master:refs/heads/master"), |
| 501 | }, |
| 502 | }, []*plumbing.Reference{ |
| 503 | plumbing.NewReferenceFromStrings("refs/heads/master", "6ecf0ef2c2dffb796033e5a02219af86ec6584e5"), |
| 504 | }) |
| 505 | } |
| 506 | |
| 507 | func (s *RemoteSuite) TestFetchFastForwardMem(c *C) { |
| 508 | s.testFetchFastForward(c, memory.NewStorage()) |
no test coverage detected