MCPcopy Create free account
hub / github.com/libgit2/git2go / TestCherrypick

Function TestCherrypick

cherrypick_test.go:35–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

33}
34
35func TestCherrypick(t *testing.T) {
36 t.Parallel()
37 repo := createTestRepo(t)
38 defer cleanupTestRepo(t, repo)
39
40 c1, _ := seedTestRepo(t, repo)
41 c2, _ := updateReadme(t, repo, content)
42
43 commit1, err := repo.LookupCommit(c1)
44 if err != nil {
45 t.Fatal(err)
46 }
47 commit2, err := repo.LookupCommit(c2)
48 if err != nil {
49 t.Fatal(err)
50 }
51
52 checkout(t, repo, commit1)
53
54 if readReadme(t, repo) == content {
55 t.Fatalf("README has wrong content after checking out initial commit")
56 }
57
58 opts, err := DefaultCherrypickOptions()
59 if err != nil {
60 t.Fatal(err)
61 }
62
63 err = repo.Cherrypick(commit2, opts)
64 if err != nil {
65 t.Fatal(err)
66 }
67
68 if readReadme(t, repo) != content {
69 t.Fatalf("README has wrong contents after cherry-picking")
70 }
71
72 state := repo.State()
73 if state != RepositoryStateCherrypick {
74 t.Fatal("Incorrect repository state: ", state)
75 }
76
77 err = repo.StateCleanup()
78 if err != nil {
79 t.Fatal(err)
80 }
81
82 state = repo.State()
83 if state != RepositoryStateNone {
84 t.Fatal("Incorrect repository state: ", state)
85 }
86}
87
88func TestCherrypickCommit(t *testing.T) {
89 t.Parallel()

Callers

nothing calls this directly

Calls 11

createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
seedTestRepoFunction · 0.85
updateReadmeFunction · 0.85
checkoutFunction · 0.85
readReadmeFunction · 0.85
DefaultCherrypickOptionsFunction · 0.85
LookupCommitMethod · 0.80
CherrypickMethod · 0.80
StateMethod · 0.80
StateCleanupMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…