Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 1edb142

Browse files
fix: add list_relevant_files to NoVersioningSystem
1 parent 079f01b commit 1edb142

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

codecov_cli/helpers/versioning_systems.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from itertools import chain
12
import logging
23
import subprocess
34
import typing as t
@@ -148,6 +149,47 @@ def list_relevant_files(
148149

149150

150151
class NoVersioningSystem(VersioningSystemInterface):
152+
@classmethod
153+
def blockdirs(cls):
154+
return [
155+
'*.egg-info',
156+
'.DS_Store',
157+
'.circleci',
158+
'.env',
159+
'.envs',
160+
'.git',
161+
'.gitignore',
162+
'.mypy_cache',
163+
'.nvmrc',
164+
'.nyc_output',
165+
'.ruff_cache',
166+
'.venv',
167+
'.venvns',
168+
'.virtualenv',
169+
'.virtualenvs',
170+
'__pycache__',
171+
'bower_components',
172+
'build/lib/',
173+
'jspm_packages',
174+
'node_modules',
175+
'vendor',
176+
'virtualenv',
177+
'virtualenvs',
178+
'build',
179+
'dist',
180+
]
181+
182+
@classmethod
183+
def blockfiles(cls):
184+
return [
185+
'*.gif',
186+
'*.jpeg',
187+
'*.jpg',
188+
'*.md',
189+
'*.png',
190+
'shunit2*',
191+
]
192+
151193
@classmethod
152194
def is_available(cls):
153195
return True
@@ -161,4 +203,15 @@ def get_fallback_value(self, fallback_field: FallbackFieldEnum):
161203
def list_relevant_files(
162204
self, directory: t.Optional[Path] = None, recurse_submodules: bool = False
163205
) -> t.List[str]:
164-
return []
206+
207+
cmd = [
208+
"find",
209+
str(directory),
210+
*list(chain(*[["-name", block, "-prune", "-o"] for block in self.__class__.blockdirs()])),
211+
*list(chain(*[["-path", block, "-prune", "-o"] for block in self.__class__.blockfiles()])),
212+
"-type",
213+
"f",
214+
"-print",
215+
]
216+
res = subprocess.run(cmd, capture_output=True)
217+
return [filename for filename in res.stdout.decode("unicode_escape").strip().split("\n") if filename]

tests/services/upload/test_upload_collector.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,10 @@ def test_generate_upload_data_with_none_network(
204204
assert res.network == []
205205
assert len(res.files) == 1
206206
assert len(res.file_fixes) == 0
207+
208+
@patch.object(GitVersioningSystem, "get_network_root", return_value=None)
209+
def test_no_versioning_file_collection(
210+
mock_get_network_root, mock_logger, tmp_path
211+
):
212+
files = NoVersioningSystem().list_relevant_files('.')
213+
assert len(files) == 1067

0 commit comments

Comments
 (0)