Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions dvc/output/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ def isdir(self):
def isfile(self):
return self.remote.isfile(self.path_info)

def ignore(self):
if not self.use_scm_ignore:
return

if self.repo.scm.is_tracked(self.fspath):
raise OutputAlreadyTrackedError(self)

self.repo.scm.ignore(self.fspath)

def save(self):
if not self.exists:
raise self.DoesNotExistError(self)
Expand All @@ -219,11 +228,7 @@ def save(self):
if self.is_empty:
logger.warning("'{}' is empty.".format(self))

if self.use_scm_ignore:
if self.repo.scm.is_tracked(self.fspath):
raise OutputAlreadyTrackedError(self)

self.repo.scm.ignore(self.fspath)
self.ignore()

if not self.use_cache:
self.info = self.save_info()
Expand Down
6 changes: 5 additions & 1 deletion dvc/repo/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ def run(self, fname=None, no_exec=False, **kwargs):
except OutputDuplicationError as exc:
raise OutputDuplicationError(exc.output, set(exc.stages) - {stage})

if not no_exec:
if no_exec:
for out in stage.outs:
out.ignore()
else:
stage.run(
no_commit=kwargs.get("no_commit", False),
ignore_build_cache=kwargs.get("ignore_build_cache", False),
)

dvcfile.dump(stage, update_pipeline=True)
return stage
8 changes: 6 additions & 2 deletions tests/func/test_run_single_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from dvc.system import System
from dvc.utils import file_md5
from dvc.utils.stage import load_stage_file
from tests.basic_env import TestDvc
from tests.basic_env import TestDvc, TestDvcGit


class TestRun(TestDvc):
Expand Down Expand Up @@ -90,13 +90,17 @@ def test(self):
)


class TestRunNoExec(TestDvc):
class TestRunNoExec(TestDvcGit):
def test(self):
self.dvc.run(
cmd="python {} {} {}".format(self.CODE, self.FOO, "out"),
deps=[self.CODE, self.FOO],
outs=["out"],
no_exec=True,
)
self.assertFalse(os.path.exists("out"))
with open(".gitignore", "r") as fobj:
self.assertEqual(fobj.read(), "/out\n")


class TestRunCircularDependency(TestDvc):
Expand Down