Skip to content

Commit ad1249c

Browse files
fix: correctly generate network if path has spaces (#357)
Parsing of output of the `ls-files` commands was splitting paths with spaces. It is literally the difference show below. ```python >>> s = 'string space\nother line\n' >>> s.split() ['string', 'space', 'other', 'line'] >>> s.split('\n') ['string space', 'other line', ''] ``` closes: #356
1 parent b46d37e commit ad1249c

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

codecov_cli/helpers/versioning_systems.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def list_relevant_files(
118118
filename[1:-1]
119119
if filename.startswith('"') and filename.endswith('"')
120120
else filename
121-
for filename in res.stdout.decode("unicode_escape").strip().split()
121+
for filename in res.stdout.decode("unicode_escape").strip().split("\n")
122122
]
123123

124124

tests/helpers/test_folder_searcher.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def test_search_files_with_folder_exclusion(tmp_path):
4343
"another/some/banana.py",
4444
"from/some/banana.py",
4545
"to/some/banana.py",
46+
"path/folder with space/banana.py",
4647
"apple.py",
4748
"banana.py",
4849
]
@@ -56,6 +57,7 @@ def test_search_files_with_folder_exclusion(tmp_path):
5657
tmp_path / "banana.py",
5758
tmp_path / "from/some/banana.py",
5859
tmp_path / "another/some/banana.py",
60+
tmp_path / "path/folder with space/banana.py",
5961
]
6062
)
6163
assert expected_results == sorted(

tests/helpers/test_versioning_systems.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_list_relevant_files_returns_correct_network_files(self, mocker, tmp_pat
9595
return_value=mocked_subprocess,
9696
)
9797
# git ls-files diplays a single \n as \\\\n
98-
mocked_subprocess.stdout = b'a.txt\nb.txt\n"a\\\\nb.txt"\nc.txt\nd.txt'
98+
mocked_subprocess.stdout = b'a.txt\nb.txt\n"a\\\\nb.txt"\nc.txt\nd.txt\n.circleci/config.yml\nLICENSE\napp/advanced calculations/advanced_calculator.js\n'
9999

100100
vs = GitVersioningSystem()
101101

@@ -105,6 +105,9 @@ def test_list_relevant_files_returns_correct_network_files(self, mocker, tmp_pat
105105
"a\\nb.txt",
106106
"c.txt",
107107
"d.txt",
108+
".circleci/config.yml",
109+
"LICENSE",
110+
"app/advanced calculations/advanced_calculator.js",
108111
]
109112

110113
def test_list_relevant_files_fails_if_no_root_is_found(self, mocker):

0 commit comments

Comments
 (0)