git: quote filenames @ remind_to_track (#3315)

Fix #3303
This commit is contained in:
Ramón Valles
2020-03-23 18:22:51 +02:00
committed by GitHub
parent 9e7740572c
commit ee26afe65e
2 changed files with 10 additions and 1 deletions
+4 -1
View File
@@ -3,6 +3,7 @@
import logging
import os
import yaml
import shlex
from funcy import cached_property
from pathspec.patterns import GitWildMatchPattern
@@ -321,11 +322,13 @@ class Git(Base):
if not self.files_to_track:
return
files = " ".join(shlex.quote(path) for path in self.files_to_track)
logger.info(
"\n"
"To track the changes with git, run:\n"
"\n"
"\tgit add {files}".format(files=" ".join(self.files_to_track))
"\tgit add {files}".format(files=files)
)
def track_file(self, path):
+6
View File
@@ -37,3 +37,9 @@ class TestScmContext(TestCase):
self.assertEqual(0, self.scm_mock.reset_ignores.call_count)
self.assertEqual(0, self.scm_mock.remind_to_track.call_count)
def test_remind_to_track(scm, caplog):
scm.files_to_track = ["fname with spaces.txt", "тест", "foo"]
scm.remind_to_track()
assert "git add 'fname with spaces.txt' 'тест' foo" in caplog.text