diff options
author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-07-15 11:17:37 +0100 |
---|---|---|
committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2022-07-15 11:46:53 +0100 |
commit | a3667ba65a1ff7959da4cb954faa46a57e42c3d8 (patch) | |
tree | c250d0125c974894fd44e9bc975f0014f5ec2ff3 | |
parent | a1bda3d984d1a40d7b00ae1d0869354d6d503001 (diff) | |
download | setuptools-scm-a3667ba65a1ff7959da4cb954faa46a57e42c3d8.tar.gz |
Add boolean flag that allows scm_find_files to bypass SCM listing
-rw-r--r-- | src/setuptools_scm/file_finder.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/setuptools_scm/file_finder.py b/src/setuptools_scm/file_finder.py index 99da792..f14a946 100644 --- a/src/setuptools_scm/file_finder.py +++ b/src/setuptools_scm/file_finder.py @@ -11,7 +11,10 @@ from .utils import trace def scm_find_files( - path: _t.PathT, scm_files: set[str], scm_dirs: set[str] + path: _t.PathT, + scm_files: set[str], + scm_dirs: set[str], + force_all_files: bool = False, ) -> list[str]: """ setuptools compatible file finder that follows symlinks @@ -20,6 +23,7 @@ def scm_find_files( (including symlinks to directories) - scm_dirs: set of scm controlled directories (including directories containing no scm controlled files) + - force_all_files: ignore ``scm_files`` and ``scm_dirs`` and list everything. scm_files and scm_dirs must be absolute with symlinks resolved (realpath), with normalized case (normcase) @@ -38,7 +42,7 @@ def scm_find_files( fn = os.path.join(realdirpath, os.path.normcase(n)) return os.path.islink(fn) and fn not in scm_files - if realdirpath not in scm_dirs: + if not force_all_files and realdirpath not in scm_dirs: # directory not in scm, don't walk it's content dirnames[:] = [] continue @@ -54,13 +58,16 @@ def scm_find_files( # symlink loop protection dirnames[:] = [] continue - dirnames[:] = [dn for dn in dirnames if not _link_not_in_scm(dn)] + dirnames[:] = [ + dn for dn in dirnames if force_all_files or not _link_not_in_scm(dn) + ] for filename in filenames: - if _link_not_in_scm(filename): + if not force_all_files and _link_not_in_scm(filename): continue # dirpath + filename with symlinks preserved fullfilename = os.path.join(dirpath, filename) - if os.path.normcase(os.path.realpath(fullfilename)) in scm_files: + is_tracked = os.path.normcase(os.path.realpath(fullfilename)) in scm_files + if force_all_files or is_tracked: res.append(os.path.join(path, os.path.relpath(fullfilename, realpath))) seen.add(realdirpath) return res |