aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_commit_test.go
diff options
context:
space:
mode:
authoronee-only <kimww0306@gmail.com>2024-03-10 08:57:11 +0900
committeronee-only <kimww0306@gmail.com>2024-03-10 08:57:11 +0900
commit74febd2e5b2428107a7a4187378bc2567bbb8076 (patch)
tree650d9545d9b91739bf0527ab7bfa3afedb8e6c14 /worktree_commit_test.go
parentd9497bae668afcc540fa6f2177575777b3ff91de (diff)
downloadgo-git-74febd2e5b2428107a7a4187378bc2567bbb8076.tar.gz
git: worktree_commit, Fix amend commit to apply changes. Fixes #1024
Diffstat (limited to 'worktree_commit_test.go')
-rw-r--r--worktree_commit_test.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/worktree_commit_test.go b/worktree_commit_test.go
index a3103b7..fee8b15 100644
--- a/worktree_commit_test.go
+++ b/worktree_commit_test.go
@@ -131,16 +131,37 @@ func (s *WorktreeSuite) TestCommitAmend(c *C) {
_, err = w.Commit("foo\n", &CommitOptions{Author: defaultSignature()})
c.Assert(err, IsNil)
+ util.WriteFile(fs, "bar", []byte("bar"), 0644)
+
+ _, err = w.Add("bar")
+ c.Assert(err, IsNil)
+
amendedHash, err := w.Commit("bar\n", &CommitOptions{Amend: true})
c.Assert(err, IsNil)
headRef, err := w.r.Head()
+ c.Assert(err, IsNil)
+
c.Assert(amendedHash, Equals, headRef.Hash())
+
commit, err := w.r.CommitObject(headRef.Hash())
c.Assert(err, IsNil)
c.Assert(commit.Message, Equals, "bar\n")
+ c.Assert(commit.NumParents(), Equals, 1)
+
+ stats, err := commit.Stats()
+ c.Assert(err, IsNil)
+ c.Assert(stats, HasLen, 2)
+ c.Assert(stats[0], Equals, object.FileStat{
+ Name: "bar",
+ Addition: 1,
+ })
+ c.Assert(stats[1], Equals, object.FileStat{
+ Name: "foo",
+ Addition: 1,
+ })
- assertStorageStatus(c, s.Repository, 13, 11, 11, amendedHash)
+ assertStorageStatus(c, s.Repository, 14, 12, 11, amendedHash)
}
func (s *WorktreeSuite) TestAddAndCommitWithSkipStatus(c *C) {