Skip to content

Commit

Permalink
fix: correctly generate network if path has spaces (#357)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
giovanni-guidini authored Jan 25, 2024
1 parent b46d37e commit ad1249c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion codecov_cli/helpers/versioning_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def list_relevant_files(
filename[1:-1]
if filename.startswith('"') and filename.endswith('"')
else filename
for filename in res.stdout.decode("unicode_escape").strip().split()
for filename in res.stdout.decode("unicode_escape").strip().split("\n")
]


Expand Down
2 changes: 2 additions & 0 deletions tests/helpers/test_folder_searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_search_files_with_folder_exclusion(tmp_path):
"another/some/banana.py",
"from/some/banana.py",
"to/some/banana.py",
"path/folder with space/banana.py",
"apple.py",
"banana.py",
]
Expand All @@ -56,6 +57,7 @@ def test_search_files_with_folder_exclusion(tmp_path):
tmp_path / "banana.py",
tmp_path / "from/some/banana.py",
tmp_path / "another/some/banana.py",
tmp_path / "path/folder with space/banana.py",
]
)
assert expected_results == sorted(
Expand Down
5 changes: 4 additions & 1 deletion tests/helpers/test_versioning_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_list_relevant_files_returns_correct_network_files(self, mocker, tmp_pat
return_value=mocked_subprocess,
)
# git ls-files diplays a single \n as \\\\n
mocked_subprocess.stdout = b'a.txt\nb.txt\n"a\\\\nb.txt"\nc.txt\nd.txt'
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'

vs = GitVersioningSystem()

Expand All @@ -105,6 +105,9 @@ def test_list_relevant_files_returns_correct_network_files(self, mocker, tmp_pat
"a\\nb.txt",
"c.txt",
"d.txt",
".circleci/config.yml",
"LICENSE",
"app/advanced calculations/advanced_calculator.js",
]

def test_list_relevant_files_fails_if_no_root_is_found(self, mocker):
Expand Down

0 comments on commit ad1249c

Please sign in to comment.