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

Method TestMergeFF

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

Source from the content-addressed store, hash-verified

441}
442
443func (s *RepositorySuite) TestMergeFF(c *C) {
444 r, err := Init(memory.NewStorage(), memfs.New())
445 c.Assert(err, IsNil)
446 c.Assert(r, NotNil)
447
448 createCommit(c, r)
449 createCommit(c, r)
450 createCommit(c, r)
451 lastCommit := createCommit(c, r)
452
453 wt, err := r.Worktree()
454 c.Assert(err, IsNil)
455
456 targetBranch := plumbing.NewBranchReferenceName("foo")
457 err = wt.Checkout(&CheckoutOptions{
458 Hash: lastCommit,
459 Create: true,
460 Branch: targetBranch,
461 })
462 c.Assert(err, IsNil)
463
464 createCommit(c, r)
465 fooHash := createCommit(c, r)
466
467 // Checkout the master branch so that we can try to merge foo into it.
468 err = wt.Checkout(&CheckoutOptions{
469 Branch: plumbing.Master,
470 })
471 c.Assert(err, IsNil)
472
473 head, err := r.Head()
474 c.Assert(err, IsNil)
475 c.Assert(head.Hash(), Equals, lastCommit)
476
477 targetRef := plumbing.NewHashReference(targetBranch, fooHash)
478 c.Assert(targetRef, NotNil)
479
480 err = r.Merge(*targetRef, MergeOptions{
481 Strategy: FastForwardMerge,
482 })
483 c.Assert(err, IsNil)
484
485 head, err = r.Head()
486 c.Assert(err, IsNil)
487 c.Assert(head.Hash(), Equals, fooHash)
488}
489
490func (s *RepositorySuite) TestMergeFF_Invalid(c *C) {
491 r, err := Init(memory.NewStorage(), memfs.New())

Callers

nothing calls this directly

Calls 10

NewStorageFunction · 0.92
NewBranchReferenceNameFunction · 0.92
NewHashReferenceFunction · 0.92
InitFunction · 0.85
createCommitFunction · 0.85
WorktreeMethod · 0.80
CheckoutMethod · 0.80
HeadMethod · 0.80
MergeMethod · 0.80
HashMethod · 0.65

Tested by

no test coverage detected