aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Sklyar <osklyar@gmx.com>2017-06-21 01:38:39 +0200
committerOleg Sklyar <osklyar@gmx.com>2017-06-21 01:38:39 +0200
commit81dbc6a6e5cf5278ba3be981247fd702d5102cef (patch)
tree6c0b6e7bc17eefb0fd2eb4af2d47c4a387d49ae2
parentdcdd9a70179b14d01c985c93ea0af717f4d88979 (diff)
downloadgo-git-81dbc6a6e5cf5278ba3be981247fd702d5102cef.tar.gz
Adds test that checkout possible with untracked files under gitignore
-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,