(c *C)
| 488 | } |
| 489 | |
| 490 | func (s *RepositorySuite) TestMergeFF_Invalid(c *C) { |
| 491 | r, err := Init(memory.NewStorage(), memfs.New()) |
| 492 | c.Assert(err, IsNil) |
| 493 | c.Assert(r, NotNil) |
| 494 | |
| 495 | // Keep track of the first commit, which will be the |
| 496 | // reference to create the target branch so that we |
| 497 | // can simulate a non-ff merge. |
| 498 | firstCommit := createCommit(c, r) |
| 499 | createCommit(c, r) |
| 500 | createCommit(c, r) |
| 501 | lastCommit := createCommit(c, r) |
| 502 | |
| 503 | wt, err := r.Worktree() |
| 504 | c.Assert(err, IsNil) |
| 505 | |
| 506 | targetBranch := plumbing.NewBranchReferenceName("foo") |
| 507 | err = wt.Checkout(&CheckoutOptions{ |
| 508 | Hash: firstCommit, |
| 509 | Create: true, |
| 510 | Branch: targetBranch, |
| 511 | }) |
| 512 | |
| 513 | c.Assert(err, IsNil) |
| 514 | |
| 515 | createCommit(c, r) |
| 516 | h := createCommit(c, r) |
| 517 | |
| 518 | // Checkout the master branch so that we can try to merge foo into it. |
| 519 | err = wt.Checkout(&CheckoutOptions{ |
| 520 | Branch: plumbing.Master, |
| 521 | }) |
| 522 | c.Assert(err, IsNil) |
| 523 | |
| 524 | head, err := r.Head() |
| 525 | c.Assert(err, IsNil) |
| 526 | c.Assert(head.Hash(), Equals, lastCommit) |
| 527 | |
| 528 | targetRef := plumbing.NewHashReference(targetBranch, h) |
| 529 | c.Assert(targetRef, NotNil) |
| 530 | |
| 531 | err = r.Merge(*targetRef, MergeOptions{ |
| 532 | Strategy: MergeStrategy(10), |
| 533 | }) |
| 534 | c.Assert(err, Equals, ErrUnsupportedMergeStrategy) |
| 535 | |
| 536 | // Failed merge operations must not change HEAD. |
| 537 | head, err = r.Head() |
| 538 | c.Assert(err, IsNil) |
| 539 | c.Assert(head.Hash(), Equals, lastCommit) |
| 540 | |
| 541 | err = r.Merge(*targetRef, MergeOptions{}) |
| 542 | c.Assert(err, Equals, ErrFastForwardMergeNotPossible) |
| 543 | |
| 544 | head, err = r.Head() |
| 545 | c.Assert(err, IsNil) |
| 546 | c.Assert(head.Hash(), Equals, lastCommit) |
| 547 | } |
nothing calls this directly
no test coverage detected