diff options
| author | Jesse Ezell <[email protected]> | 2014-03-20 21:56:41 -0700 |
|---|---|---|
| committer | Jesse Ezell <[email protected]> | 2014-03-20 21:56:41 -0700 |
| commit | d0b334b24409ddc190a7010be0072d87df6b6bfe (patch) | |
| tree | fb434c1f8182296b2a80bdf1939e09ddca021e68 /git_test.go | |
| parent | 9acd67e388b6fccf982c9206dc5326ae35c13f49 (diff) | |
cleanup and refactor diff / patch
Diffstat (limited to 'git_test.go')
| -rw-r--r-- | git_test.go | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/git_test.go b/git_test.go index 52aea1d..2f586b5 100644 --- a/git_test.go +++ b/git_test.go @@ -1,8 +1,8 @@ package git import ( - "testing" "io/ioutil" + "testing" "time" ) @@ -14,7 +14,7 @@ func createTestRepo(t *testing.T) *Repository { checkFatal(t, err) tmpfile := "README" - err = ioutil.WriteFile(path + "/" + tmpfile, []byte("foo\n"), 0644) + err = ioutil.WriteFile(path+"/"+tmpfile, []byte("foo\n"), 0644) checkFatal(t, err) return repo @@ -45,3 +45,31 @@ func seedTestRepo(t *testing.T, repo *Repository) (*Oid, *Oid) { return commitId, treeId } +func updateReadme(t *testing.T, repo *Repository, content string) (*Oid, *Oid) { + loc, err := time.LoadLocation("Europe/Berlin") + checkFatal(t, err) + sig := &Signature{ + Name: "Rand Om Hacker", + Email: "[email protected]", + When: time.Date(2013, 03, 06, 14, 30, 0, 0, loc), + } + + tmpfile := "README" + err = ioutil.WriteFile(repo.Path()+"/"+tmpfile, []byte(content), 0644) + checkFatal(t, err) + + idx, err := repo.Index() + checkFatal(t, err) + err = idx.AddByPath("README") + checkFatal(t, err) + treeId, err := idx.WriteTree() + checkFatal(t, err) + + message := "This is a commit\n" + tree, err := repo.LookupTree(treeId) + checkFatal(t, err) + commitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree) + checkFatal(t, err) + + return commitId, treeId +} |
