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

Function TestCreateCommitFromIds

repository_test.go:62–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

60}
61
62func TestCreateCommitFromIds(t *testing.T) {
63 t.Parallel()
64 repo := createTestRepo(t)
65 defer cleanupTestRepo(t, repo)
66
67 loc, err := time.LoadLocation("Europe/Berlin")
68 checkFatal(t, err)
69 sig := &Signature{
70 Name: "Rand Om Hacker",
71 Email: "random@hacker.com",
72 When: time.Date(2013, 03, 06, 14, 30, 0, 0, loc),
73 }
74
75 idx, err := repo.Index()
76 checkFatal(t, err)
77 err = idx.AddByPath("README")
78 checkFatal(t, err)
79 err = idx.Write()
80 checkFatal(t, err)
81 treeId, err := idx.WriteTree()
82 checkFatal(t, err)
83
84 message := "This is a commit\n"
85 tree, err := repo.LookupTree(treeId)
86 checkFatal(t, err)
87 expectedCommitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree)
88 checkFatal(t, err)
89
90 commitId, err := repo.CreateCommitFromIds("", sig, sig, message, treeId)
91 checkFatal(t, err)
92
93 if !expectedCommitId.Equal(commitId) {
94 t.Errorf("mismatched commit ids, expected %v, got %v", expectedCommitId.String(), commitId.String())
95 }
96}
97
98func TestRepositorySetConfig(t *testing.T) {
99 repo := createTestRepo(t)

Callers

nothing calls this directly

Calls 12

createTestRepoFunction · 0.85
cleanupTestRepoFunction · 0.85
checkFatalFunction · 0.85
AddByPathMethod · 0.80
WriteTreeMethod · 0.80
LookupTreeMethod · 0.80
CreateCommitMethod · 0.80
CreateCommitFromIdsMethod · 0.80
EqualMethod · 0.80
IndexMethod · 0.45
WriteMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…