aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--worktree_test.go34
1 files changed, 30 insertions, 4 deletions
diff --git a/worktree_test.go b/worktree_test.go
index 5d0d131..875f8d5 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -307,6 +307,35 @@ func (s *WorktreeSuite) testCheckoutBisect(c *C, url string) {
})
}
+func (s *WorktreeSuite) TestCheckoutWithGitignore(c *C) {
+ fs := memfs.New()
+ w := &Worktree{
+ r: s.Repository,
+ fs: fs,
+ }
+
+ err := w.Checkout(&CheckoutOptions{})
+ c.Assert(err, IsNil)
+
+ f, _ := fs.Create("file")
+ f.Close()
+
+ err = w.Checkout(&CheckoutOptions{})
+ c.Assert(err.Error(), Equals, "worktree contains unstagged changes")
+
+ f, _ = fs.Create(".gitignore")
+ f.Write([]byte("file"))
+ f.Close()
+
+ err = w.Checkout(&CheckoutOptions{})
+ c.Assert(err.Error(), Equals, "worktree contains unstagged changes")
+
+ w.Add(".gitignore")
+
+ err = w.Checkout(&CheckoutOptions{})
+ c.Assert(err, IsNil)
+}
+
func (s *WorktreeSuite) TestStatus(c *C) {
fs := memfs.New()
w := &Worktree{
@@ -458,10 +487,7 @@ func (s *WorktreeSuite) TestStatusModified(c *C) {
}
func (s *WorktreeSuite) TestStatusIgnored(c *C) {
- dir, _ := ioutil.TempDir("", "status")
- defer os.RemoveAll(dir)
-
- fs := osfs.New(filepath.Join(dir, "worktree"))
+ fs := memfs.New()
w := &Worktree{
r: s.Repository,
fs: fs,