aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_commit_test.go
diff options
context:
space:
mode:
authorgrunenwflorian <florian.grunenwald1@gmail.com>2017-09-05 11:28:36 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-09-05 11:28:36 +0200
commita33a60d244f94a07adeb70cfe938c97651c0ddc9 (patch)
treed8d1f4f009951bc84162c646d9a86084e01eb5ed /worktree_commit_test.go
parentf9879dd043f84936a1f8acb8a53b74332a7ae135 (diff)
downloadgo-git-a33a60d244f94a07adeb70cfe938c97651c0ddc9.tar.gz
Worktree.Add: Support Add deleted files, fixes #571 (#577)
Diffstat (limited to 'worktree_commit_test.go')
-rw-r--r--worktree_commit_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/worktree_commit_test.go b/worktree_commit_test.go
index f6744bc..09360af 100644
--- a/worktree_commit_test.go
+++ b/worktree_commit_test.go
@@ -99,6 +99,42 @@ func (s *WorktreeSuite) TestCommitAll(c *C) {
assertStorageStatus(c, s.Repository, 13, 11, 10, expected)
}
+func (s *WorktreeSuite) TestRemoveAndCommitAll(c *C) {
+ expected := plumbing.NewHash("907cd576c6ced2ecd3dab34a72bf9cf65944b9a9")
+
+ fs := memfs.New()
+ w := &Worktree{
+ r: s.Repository,
+ Filesystem: fs,
+ }
+
+ err := w.Checkout(&CheckoutOptions{})
+ c.Assert(err, IsNil)
+
+ util.WriteFile(fs, "foo", []byte("foo"), 0644)
+ _, err = w.Add("foo")
+ c.Assert(err, IsNil)
+
+ _, errFirst := w.Commit("Add in Repo\n", &CommitOptions{
+ Author: defaultSignature(),
+ })
+ c.Assert(errFirst, IsNil)
+
+ errRemove := fs.Remove("foo")
+ c.Assert(errRemove, IsNil)
+
+ hash, errSecond := w.Commit("Remove foo\n", &CommitOptions{
+ All: true,
+ Author: defaultSignature(),
+ })
+ c.Assert(errSecond, IsNil)
+
+ c.Assert(hash, Equals, expected)
+ c.Assert(err, IsNil)
+
+ assertStorageStatus(c, s.Repository, 13, 11, 11, expected)
+}
+
func assertStorageStatus(
c *C, r *Repository,
treesCount, blobCount, commitCount int, head plumbing.Hash,