aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-05-03 21:54:32 +0100
committerGitHub <noreply@github.com>2023-05-03 21:54:32 +0100
commitda73c5f950fb399611e3eb608f6ee99f23eb53b5 (patch)
tree9448e13e7a711172b3623d72259f0a353afeee68 /worktree_test.go
parent4c53decce0448efa6da0cfc4939693cb4e378648 (diff)
parentcf51e2febf37332f11ae63feca768d9672e10a36 (diff)
downloadgo-git-da73c5f950fb399611e3eb608f6ee99f23eb53b5.tar.gz
Merge pull request #719 from cbbm142/master
git: worktree, add check to see if file already checked in. Fixes #718
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go
index 1d6a05f..4f55844 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -871,6 +871,51 @@ func (s *WorktreeSuite) TestStatusEmpty(c *C) {
c.Assert(status, NotNil)
}
+func (s *WorktreeSuite) TestStatusCheckedInBeforeIgnored(c *C) {
+ fs := memfs.New()
+ storage := memory.NewStorage()
+
+ r, err := Init(storage, fs)
+ c.Assert(err, IsNil)
+
+ w, err := r.Worktree()
+ c.Assert(err, IsNil)
+
+ err = util.WriteFile(fs, "fileToIgnore", []byte("Initial data"), 0755)
+ c.Assert(err, IsNil)
+ _, err = w.Add("fileToIgnore")
+ c.Assert(err, IsNil)
+ _, err = w.Commit("Added file that will be ignored later", &CommitOptions{})
+ c.Assert(err, IsNil)
+
+ err = util.WriteFile(fs, ".gitignore", []byte("fileToIgnore\nsecondIgnoredFile"), 0755)
+ c.Assert(err, IsNil)
+ _, err = w.Add(".gitignore")
+ c.Assert(err, IsNil)
+ _, err = w.Commit("Added .gitignore", &CommitOptions{})
+ c.Assert(err, IsNil)
+ status, err := w.Status()
+ c.Assert(err, IsNil)
+ c.Assert(status.IsClean(), Equals, true)
+ c.Assert(status, NotNil)
+
+ err = util.WriteFile(fs, "secondIgnoredFile", []byte("Should be completly ignored"), 0755)
+ c.Assert(err, IsNil)
+ status = nil
+ status, err = w.Status()
+ c.Assert(err, IsNil)
+ c.Assert(status.IsClean(), Equals, true)
+ c.Assert(status, NotNil)
+
+ err = util.WriteFile(fs, "fileToIgnore", []byte("Updated data"), 0755)
+ c.Assert(err, IsNil)
+ status = nil
+ status, err = w.Status()
+ c.Assert(err, IsNil)
+ c.Assert(status.IsClean(), Equals, false)
+ c.Assert(status, NotNil)
+}
+
func (s *WorktreeSuite) TestStatusEmptyDirty(c *C) {
fs := memfs.New()
err := util.WriteFile(fs, "foo", []byte("foo"), 0755)