From 441fc3ad97b8cd2c66d9591705ca50db4a0d4375 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 6 Feb 2019 14:25:48 +0200 Subject: [PATCH] add: don't try to save cached stages Cached stages are already saved, so there is no need to try to save them once again. Fixes #1581 Signed-off-by: Ruslan Kuprieiev --- dvc/project.py | 3 ++- tests/test_add.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dvc/project.py b/dvc/project.py index 57b586c9f..e198d3499 100644 --- a/dvc/project.py +++ b/dvc/project.py @@ -229,7 +229,8 @@ class Project(object): self._check_dag(self.stages() + stages) for stage in stages: - stage.dump() + if stage is not None: + stage.dump() self._remind_to_git_add() diff --git a/tests/test_add.py b/tests/test_add.py index 7ccc109a7..085c752c8 100644 --- a/tests/test_add.py +++ b/tests/test_add.py @@ -188,3 +188,19 @@ class TestCmdAdd(TestDvc): ret = main(["add", "non-existing-file"]) self.assertNotEqual(ret, 0) + + +class TestDoubleAddUnchanged(TestDvc): + def test_file(self): + ret = main(["add", self.FOO]) + self.assertEqual(ret, 0) + + ret = main(["add", self.FOO]) + self.assertEqual(ret, 0) + + def test_dir(self): + ret = main(["add", self.DATA_DIR]) + self.assertEqual(ret, 0) + + ret = main(["add", self.DATA_DIR]) + self.assertEqual(ret, 0)