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

Function updateReadme

git_test.go:148–182  ·  view source on GitHub ↗
(t *testing.T, repo *Repository, content string)

Source from the content-addressed store, hash-verified

146}
147
148func updateReadme(t *testing.T, repo *Repository, content string) (*Oid, *Oid) {
149 loc, err := time.LoadLocation("Europe/Berlin")
150 checkFatal(t, err)
151 sig := &Signature{
152 Name: "Rand Om Hacker",
153 Email: "random@hacker.com",
154 When: time.Date(2013, 03, 06, 14, 30, 0, 0, loc),
155 }
156
157 tmpfile := "README"
158 err = ioutil.WriteFile(pathInRepo(repo, tmpfile), []byte(content), 0644)
159 checkFatal(t, err)
160
161 idx, err := repo.Index()
162 checkFatal(t, err)
163 err = idx.AddByPath("README")
164 checkFatal(t, err)
165 err = idx.Write()
166 checkFatal(t, err)
167 treeId, err := idx.WriteTree()
168 checkFatal(t, err)
169
170 currentBranch, err := repo.Head()
171 checkFatal(t, err)
172 currentTip, err := repo.LookupCommit(currentBranch.Target())
173 checkFatal(t, err)
174
175 message := "This is a commit\n"
176 tree, err := repo.LookupTree(treeId)
177 checkFatal(t, err)
178 commitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree, currentTip)
179 checkFatal(t, err)
180
181 return commitId, treeId
182}
183
184func TestOidZero(t *testing.T) {
185 t.Parallel()

Callers 14

TestPatchFunction · 0.85
TestBlameFunction · 0.85
TestRevertFunction · 0.85
TestRevertCommitFunction · 0.85
TestNoteIteratorFunction · 0.85
TestCherrypickFunction · 0.85
TestCherrypickCommitFunction · 0.85
TestResetToCommitFunction · 0.85
createTestTreesFunction · 0.85
TestListTagsFunction · 0.85
TestListTagsWithMatchFunction · 0.85
TestTagForeachFunction · 0.85

Calls 11

checkFatalFunction · 0.85
pathInRepoFunction · 0.85
AddByPathMethod · 0.80
WriteTreeMethod · 0.80
HeadMethod · 0.80
LookupCommitMethod · 0.80
LookupTreeMethod · 0.80
CreateCommitMethod · 0.80
IndexMethod · 0.45
WriteMethod · 0.45
TargetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…