mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
run: ask for confirmation when overwriting stage file
Fixes #974 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+2
-1
@@ -218,7 +218,8 @@ class Project(object):
|
||||
outs=outs,
|
||||
outs_no_cache=outs_no_cache,
|
||||
metrics_no_cache=metrics_no_cache,
|
||||
deps=deps)
|
||||
deps=deps,
|
||||
overwrite=False)
|
||||
if not no_exec:
|
||||
stage.run()
|
||||
stage.dump()
|
||||
|
||||
+9
-1
@@ -8,6 +8,7 @@ import posixpath
|
||||
import dvc.dependency as dependency
|
||||
import dvc.output as output
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.prompt import prompt
|
||||
from dvc.logger import Logger
|
||||
from dvc.utils import dict_md5
|
||||
|
||||
@@ -227,7 +228,8 @@ class Stage(object):
|
||||
fname=None,
|
||||
cwd=os.curdir,
|
||||
locked=False,
|
||||
add=False):
|
||||
add=False,
|
||||
overwrite=True):
|
||||
stage = Stage(project=project,
|
||||
cwd=cwd,
|
||||
cmd=cmd,
|
||||
@@ -244,6 +246,12 @@ class Stage(object):
|
||||
cwd = os.path.abspath(cwd)
|
||||
path = os.path.join(cwd, fname)
|
||||
|
||||
if os.path.exists(path):
|
||||
relpath = os.path.relpath(path)
|
||||
msg = "{} already exists. Do you wish to overwrite it?"
|
||||
if not overwrite and not prompt(msg.format(relpath), False):
|
||||
raise DvcException("{} already exists".format(relpath))
|
||||
|
||||
stage.cwd = cwd
|
||||
stage.path = path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user