From 300332e223a3755be961174a5eba8815ad393fcb Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sun, 10 Dec 2017 05:39:12 +0200 Subject: [PATCH] run: create 'Dvcfile' by default Fixes #344 Signed-off-by: Ruslan Kuprieiev --- dvc/cli.py | 3 ++- dvc/git_wrapper.py | 13 ------------- dvc/state_file.py | 6 ++++-- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/dvc/cli.py b/dvc/cli.py index 9553e8cd3..81d3de2a1 100644 --- a/dvc/cli.py +++ b/dvc/cli.py @@ -19,6 +19,7 @@ from dvc.command.config import CmdConfig from dvc.command.show_pipeline import CmdShowPipeline from dvc.command.merge import CmdMerge from dvc.command.checkout import CmdCheckout +from dvc.state_file import StateFile from dvc import VERSION @@ -115,7 +116,7 @@ def parse_args(argv=None): help='Lock data item - disable reproduction.') run_parser.add_argument('-f', '--file', - default='stage.dvc', + default=StateFile.DVCFILE_NAME, help='Specify name of the state file') run_parser.add_argument( 'command', diff --git a/dvc/git_wrapper.py b/dvc/git_wrapper.py index 769ae7639..f9eb9d45c 100644 --- a/dvc/git_wrapper.py +++ b/dvc/git_wrapper.py @@ -419,19 +419,6 @@ class GitWrapper(GitWrapperI): return '' return out - @staticmethod - def state_files_for_previous_commit(): - commit = GitWrapper.git_prev_commit() - Logger.debug(u'[dvc-git] Previous commit "{}"'.format(commit)) - - if not commit: - Logger.debug(u'[dvc-git] Previous commit does not exist') - return [] - - git_cmd = u'git ls-tree --name-only -r {}'.format(commit) - lines = Executor.exec_cmd_only_success(git_cmd.split()).split('\n') - return list(filter(lambda s: s.endswith(DataItem.STATE_FILE_SUFFIX), lines)) - @staticmethod def branches(regexp): cmd = 'git branch --format "%(refname)"' diff --git a/dvc/state_file.py b/dvc/state_file.py index 42ad1e717..1cdbb4b0e 100644 --- a/dvc/state_file.py +++ b/dvc/state_file.py @@ -25,6 +25,7 @@ class StateFileBase(object): class StateFile(StateFileBase): + DVCFILE_NAME = 'Dvcfile' STATE_FILE_SUFFIX = '.dvc' PARAM_CMD = 'cmd' @@ -84,7 +85,9 @@ class StateFile(StateFileBase): @staticmethod def _is_state_file(path): - return path.endswith(StateFile.STATE_FILE_SUFFIX) and os.path.isfile(path) + return (path.endswith(StateFile.STATE_FILE_SUFFIX) or \ + os.path.basename(path) == StateFile.DVCFILE_NAME) and \ + os.path.isfile(path) @staticmethod def _find_state(fname, dname): @@ -92,7 +95,6 @@ class StateFile(StateFileBase): for entry in os.listdir(dname): state_file = os.path.join(dname, entry) if not StateFile._is_state_file(state_file): -# if not state_file.endswith(StateFile.STATE_FILE_SUFFIX) or not os.path.isfile(state_file): continue state = StateFile.load(os.path.join(dname, state_file)) if name in state.out: