mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
repro/exp run: use git status when reminding to git-track files (#5544)
* repro: skip DVC deps in SCM track stage (DVC deps will be tracked when their own stage is repro'd) * scm: use git status when reminding to git-track files * sort names in reminder instead of random set order * update unit test
This commit is contained in:
@@ -61,7 +61,11 @@ def _track_stage(stage):
|
||||
|
||||
stage.repo.scm.track_file(stage.dvcfile.relpath)
|
||||
for dep in stage.deps:
|
||||
if not dep.use_scm_ignore and dep.is_in_repo:
|
||||
if (
|
||||
not dep.use_scm_ignore
|
||||
and dep.is_in_repo
|
||||
and not stage.repo.repo_fs.isdvc(dep.path_info)
|
||||
):
|
||||
stage.repo.scm.track_file(relpath(dep.path_info))
|
||||
for out in stage.outs:
|
||||
if not out.use_scm_ignore and out.is_in_repo:
|
||||
|
||||
+11
-2
@@ -272,10 +272,19 @@ class Git(Base):
|
||||
self.files_to_track = set()
|
||||
|
||||
def remind_to_track(self):
|
||||
if self.quiet or not self.files_to_track:
|
||||
def _filter(files):
|
||||
if not files:
|
||||
return set()
|
||||
staged, unstaged, untracked = self.status()
|
||||
return files.intersection(
|
||||
staged.get("modify", []) + unstaged + untracked
|
||||
)
|
||||
|
||||
files_to_track = _filter(self.files_to_track)
|
||||
if self.quiet or not files_to_track:
|
||||
return
|
||||
|
||||
files = " ".join(shlex.quote(path) for path in self.files_to_track)
|
||||
files = " ".join(shlex.quote(path) for path in sorted(files_to_track))
|
||||
|
||||
logger.info(
|
||||
"\n"
|
||||
|
||||
@@ -509,10 +509,20 @@ def test_reset(tmp_dir, scm, git):
|
||||
assert len(unstaged) == 2
|
||||
|
||||
|
||||
def test_remind_to_track(scm, caplog):
|
||||
scm.files_to_track = ["fname with spaces.txt", "тест", "foo"]
|
||||
def test_remind_to_track(tmp_dir, scm, caplog):
|
||||
files = ["fname with spaces.txt", "тест", "foo"]
|
||||
tmp_dir.gen({name: "foo" for name in files})
|
||||
scm.files_to_track.update(files)
|
||||
|
||||
scm.remind_to_track()
|
||||
assert "git add 'fname with spaces.txt' 'тест' foo" in caplog.text
|
||||
assert "git add 'fname with spaces.txt' foo 'тест'" in caplog.text
|
||||
|
||||
scm.add(["foo"])
|
||||
caplog.clear()
|
||||
|
||||
scm.remind_to_track()
|
||||
assert "git add 'fname with spaces.txt' 'тест'" in caplog.text
|
||||
assert "foo" not in caplog.text
|
||||
|
||||
|
||||
def test_add(tmp_dir, scm, git):
|
||||
|
||||
Reference in New Issue
Block a user