diff --git a/dvc/stage.py b/dvc/stage.py index 4bd12d16e..3a49544ba 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -293,7 +293,8 @@ class Stage(object): def remove_outs(self): for out in self.outs: out.remove() - self.project.scm.ignore_remove(out.path) + if out.use_cache: + self.project.scm.ignore_remove(out.path) def remove(self): self.remove_outs() @@ -353,7 +354,8 @@ class Stage(object): for out in self.outs: out.update() out.save() - self.project.scm.ignore(out.path) + if out.use_cache: + self.project.scm.ignore(out.path) def run(self): if not self.is_data_source: diff --git a/tests/test_checkout.py b/tests/test_checkout.py index 9a079cbde..8528dd7b4 100644 --- a/tests/test_checkout.py +++ b/tests/test_checkout.py @@ -75,6 +75,7 @@ class TestGitIgnoreBasic(CheckoutBase): def test(self): fname1 = 'file_1' fname2 = 'file_2' + fname3 = 'file_3' self.dvc.scm.add(self.dvc.scm.untracked_files()) self.dvc.scm.commit('add all files') @@ -83,15 +84,18 @@ class TestGitIgnoreBasic(CheckoutBase): self.commit_data_file(fname1) self.commit_data_file(fname2) + self.dvc.run(cmd='python {} {} {}'.format(self.CODE, self.FOO, fname3), + deps=[self.CODE, self.FOO], + outs_no_cache=[fname3]) self.assertTrue(os.path.exists(self.GIT_IGNORE)) ignored = self.read_ignored() - self.assertEqual(len(ignored), 2) # FAILS!!! + self.assertEqual(len(ignored), 2) self.assertIn(fname1, ignored) - self.assertIn(fname2, ignored) # FAILS!!! + self.assertIn(fname2, ignored) class TestGitIgnoreWhenCheckout(CheckoutBase): @@ -120,4 +124,4 @@ class TestGitIgnoreWhenCheckout(CheckoutBase): self.dvc.scm.checkout(branch_1) main(['checkout']) ignored = self.read_ignored() - self.assertIn(fname_branch, ignored) # FAILS!!! + self.assertIn(fname_branch, ignored)