test: adjust to safe commit append

When we create a commit and tell the library to update a ref, we need to
make sure to pass the current tip.

This is what we should have been doing in a function called
'upateReadme()' anyway. The existing code creates a new root commit,
which is not an update.
This commit is contained in:
Carlos Martín Nieto 2014-05-03 19:13:32 +02:00
parent 9c72700765
commit 9b4c865f18
1 changed files with 6 additions and 1 deletions

View File

@ -77,10 +77,15 @@ func updateReadme(t *testing.T, repo *Repository, content string) (*Oid, *Oid) {
treeId, err := idx.WriteTree() treeId, err := idx.WriteTree()
checkFatal(t, err) checkFatal(t, err)
currentBranch, err := repo.Head()
checkFatal(t, err)
currentTip, err := repo.LookupCommit(currentBranch.Target())
checkFatal(t, err)
message := "This is a commit\n" message := "This is a commit\n"
tree, err := repo.LookupTree(treeId) tree, err := repo.LookupTree(treeId)
checkFatal(t, err) checkFatal(t, err)
commitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree) commitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree, currentTip)
checkFatal(t, err) checkFatal(t, err)
return commitId, treeId return commitId, treeId