From b284d61ee7a88700d141934ae93431fdb454463d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= Date: Wed, 14 Jul 2021 19:52:16 +0200 Subject: [PATCH] Files autodetection fixes Do not include subdirectories as %doc. Fix #136. Sort license and doc files alphabetically. Fix #135. Only include doc files from the root directory. Fix #134. --- rust2rpm/__main__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rust2rpm/__main__.py b/rust2rpm/__main__.py index 673ade7..3dc79e3 100644 --- a/rust2rpm/__main__.py +++ b/rust2rpm/__main__.py @@ -211,12 +211,11 @@ def get_license_files(path): for root, dirs, files in os.walk(path, topdown=True): dirs[:] = [d for d in dirs if d not in exclude] license_files.extend([os.path.relpath(os.path.join(root, f), path) for f in files if LICENSES.match(f)]) + license_files.sort() return license_files def get_doc_files(path): doc_files = [] - include = {"doc", "docs", "example", "examples", "_example", "_examples"} - exclude = {"vendor", ".github", "tests", "test", ".circleci"} matcher = re.compile( r"(.*\.md|.*\.markdown|.*\.mdown|.*\.mkdn|.*\.rst|.*\.txt|AUTHORS|" r"AUTHORS[\.\-].*|CONTRIBUTORS|CONTRIBUTORS[\.\-].*|README|" @@ -224,9 +223,9 @@ def get_doc_files(path): re.IGNORECASE) matcherex = re.compile(r"CMakeLists\.txt") for root, dirs, files in os.walk(path, topdown=True): - doc_files = doc_files + [d for d in dirs if d in include] - dirs[:] = [d for d in dirs if d not in exclude] + dirs[:] = [] doc_files.extend([os.path.relpath(os.path.join(root, f), path) for f in files if matcher.match(f) and not LICENSES.match(f) and not matcherex.match(f)]) + doc_files.sort() return doc_files def make_diff_metadata(crate, version, patch=False, store=False):