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

Function prepareStashRepo

stash_test.go:154–191  ·  view source on GitHub ↗
(t *testing.T, repo *Repository)

Source from the content-addressed store, hash-verified

152}
153
154func prepareStashRepo(t *testing.T, repo *Repository) {
155 seedTestRepo(t, repo)
156
157 err := ioutil.WriteFile(pathInRepo(repo, ".gitignore"), []byte("tmp\n"), 0644)
158 checkFatal(t, err)
159
160 sig := &Signature{
161 Name: "Rand Om Hacker",
162 Email: "random@hacker.com",
163 When: time.Now(),
164 }
165
166 idx, err := repo.Index()
167 checkFatal(t, err)
168 err = idx.AddByPath(".gitignore")
169 checkFatal(t, err)
170 treeID, err := idx.WriteTree()
171 checkFatal(t, err)
172 err = idx.Write()
173 checkFatal(t, err)
174
175 currentBranch, err := repo.Head()
176 checkFatal(t, err)
177 currentTip, err := repo.LookupCommit(currentBranch.Target())
178 checkFatal(t, err)
179
180 message := "Add .gitignore\n"
181 tree, err := repo.LookupTree(treeID)
182 checkFatal(t, err)
183 _, err = repo.CreateCommit("HEAD", sig, sig, message, tree, currentTip)
184 checkFatal(t, err)
185
186 err = ioutil.WriteFile(pathInRepo(repo, "README"), []byte("Update README goes to stash\n"), 0644)
187 checkFatal(t, err)
188
189 err = ioutil.WriteFile(pathInRepo(repo, "untracked.txt"), []byte("Hello, World\n"), 0644)
190 checkFatal(t, err)
191}
192
193func fileExistsInRepo(repo *Repository, name string) bool {
194 if _, err := os.Stat(pathInRepo(repo, name)); err != nil {

Callers 1

TestStashFunction · 0.85

Calls 12

seedTestRepoFunction · 0.85
pathInRepoFunction · 0.85
checkFatalFunction · 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…