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

Function TestRevertCommit

revert_test.go:49–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestRevertCommit(t *testing.T) {
50 t.Parallel()
51 repo := createTestRepo(t)
52 defer cleanupTestRepo(t, repo)
53
54 seedTestRepo(t, repo)
55 commitID, _ := updateReadme(t, repo, content)
56
57 commit, err := repo.LookupCommit(commitID)
58 checkFatal(t, err)
59
60 revertOptions, err := DefaultRevertOptions()
61 checkFatal(t, err)
62
63 index, err := repo.RevertCommit(commit, commit, 0, &revertOptions.MergeOptions)
64 checkFatal(t, err)
65 defer index.Free()
66
67 err = repo.CheckoutIndex(index, &revertOptions.CheckoutOptions)
68 checkFatal(t, err)
69
70 actualReadmeContents := readReadme(t, repo)
71
72 if actualReadmeContents != expectedRevertedReadmeContents {
73 t.Fatalf(`README has incorrect contents after revert. Expected: "%v", Actual: "%v"`,
74 expectedRevertedReadmeContents, actualReadmeContents)
75 }
76}

Callers

nothing calls this directly

Calls 11

createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
seedTestRepoFunction · 0.85
updateReadmeFunction · 0.85
checkFatalFunction · 0.85
DefaultRevertOptionsFunction · 0.85
readReadmeFunction · 0.85
LookupCommitMethod · 0.80
RevertCommitMethod · 0.80
CheckoutIndexMethod · 0.80
FreeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…