Repository: iterative/dvc

Issue:
Repro does not trigger if one of the dependency files was changed
ReproChangedDependency test works but it actually works incorrectly. It supposes to trigger by file content change.


Discussion:

Resolving patch:
diff --git a/dvc/command/repro.py b/dvc/command/repro.py
--- a/dvc/command/repro.py
+++ b/dvc/command/repro.py
@@ -31,7 +31,6 @@ def define_args(self, parser):
         parser.add_argument('target', metavar='', help='Data item to reproduce', nargs='*')
         pass
 
-
     @property
     def is_reproducible(self):
         return True
@@ -78,7 +77,8 @@ def repro_data_items(self, data_item_list):
 
         for data_item in data_item_list:
             try:
-                repro_change = ReproChange(data_item, self)
+                target_commit = self.git.get_target_commit(data_item.data.relative)
+                repro_change = ReproChange(data_item, self, target_commit)
                 if repro_change.reproduce():
                     changed = True
                     Logger.info(u'Data item "{}" was reproduced.'.format(
@@ -103,7 +103,7 @@ def repro_data_items(self, data_item_list):
 
 
 class ReproChange(object):
-    def __init__(self, data_item, cmd_obj):
+    def __init__(self, data_item, cmd_obj, target_commit):
         self._data_item = data_item
         self.git = cmd_obj.git
         self._cmd_obj = cmd_obj
@@ -111,6 +111,8 @@ def __init__(self, data_item, cmd_obj):
 
         cmd_obj._code = self.state.code_dependencies
 
+        self._target_commit = target_commit
+
         argv = self.state.norm_argv
 
         if not argv:
@@ -156,13 +158,13 @@ def reproduce(self, force=False):
 
         were_input_files_changed = False
         for data_item in self.dependencies:
-            change = ReproChange(data_item, self._cmd_obj)
+            change = ReproChange(data_item, self._cmd_obj, self._target_commit)
             if change.reproduce(force):
                 were_input_files_changed = True
 
-        was_source_code_changed = self.git.were_files_changed(self._data_item.data.relative,
-                                                              self.state.code_dependencies + self.state.input_files,
-                                                              self.cmd_obj.settings.path_factory)
+        was_source_code_changed = self.git.were_files_changed(self.state.code_dependencies + self.state.input_files,
+                                                              self.cmd_obj.settings.path_factory,
+                                                              self._target_commit)
         if was_source_code_changed:
             Logger.debug('Dependencies were changed for "{}"'.format(self._data_item.data.dvc))
 
diff --git a/dvc/git_wrapper.py b/dvc/git_wrapper.py
--- a/dvc/git_wrapper.py
+++ b/dvc/git_wrapper.py
@@ -157,18 +157,15 @@ def dvc_paths_to_abs(self, files):
 
         return results
 
-    def were_files_changed(self, file, code_dependencies, path_factory):
-        Logger.debug('[Git] Identify changes. Commands: {} {} && {}'.format(
-            'git log -1 --pretty=format:"%h"', file, 'git diff --name-only HEAD *'))
+    def were_files_changed(self, code_dependencies, path_factory, target_commit):
+        Logger.debug('[Git] Identify changes. Command: git diff --name-only HEAD {}'.format(
+                     target_commit))
 
-        commit = Executor.exec_cmd_only_success(['git', 'log', '-1', '--pretty=format:"%h"', file])
-        commit = commit.strip('"')
-
-        changed_files = Executor.exec_cmd_only_success(['git', 'diff', '--name-only', 'HEAD', commit])
+        changed_files = Executor.exec_cmd_only_success(['git', 'diff', '--name-only', 'HEAD', target_commit])
         changed_files = changed_files.strip('"')
 
         Logger.debug('[Git] Identify changes. Success. Changed files: {}'.format(
-            changed_files.replace('\n', ', ')))
+                     changed_files.replace('\n', ', ')))
 
         code_files, code_dirs = self.separate_dependency_files_and_dirs(code_dependencies)
         code_files_set = set([path_factory.path(x).dvc for x in code_files])
@@ -182,6 +179,11 @@ def were_files_changed(self, file, code_dependencies, path_factory):
 
         return False
 
+    @staticmethod
+    def get_target_commit(file):
+        commit = Executor.exec_cmd_only_success(['git', 'log', '-1', '--pretty=format:"%h"', file])
+        return commit.strip('"')
+
     def separate_dependency_files_and_dirs(self, code_dependencies):
         code_files = []
         code_dirs = []
diff --git a/dvc/runtime.py b/dvc/runtime.py
--- a/dvc/runtime.py
+++ b/dvc/runtime.py
@@ -12,11 +12,6 @@
 class Runtime(object):
     CONFIG = 'dvc.conf'
 
-    @staticmethod
-    def symlink_setup():
-        if os.name != 'nt':
-            return
-
     @staticmethod
     def conf_file_path(git_dir):
         return System.realpath(os.path.join(git_dir, Runtime.CONFIG))
@@ -24,7 +19,6 @@ def conf_file_path(git_dir):
     @staticmethod
     def run(cmd_class, parse_config=True):
         try:
-            Runtime.symlink_setup()
             runtime_git = GitWrapper()
 
             if parse_config:


Test patch: