From ca65fdb212af114a4625dee8a9211ca08a6bbe23 Mon Sep 17 00:00:00 2001 From: Andy Date: Sat, 17 Dec 2022 21:27:33 -0500 Subject: [PATCH 1/3] Add a case_conflict.py to check for case-only file conflicts. This is confusing and can cause issues for folks running case insensitive filesystems (happens in windows sometimes). If there is a conflict the pages in question are output. And you get an non-zero exit status. E.g. Conflict! ../../README.md ../../Readme.md --- .github/scripts/case_conflicts.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 .github/scripts/case_conflicts.py diff --git a/.github/scripts/case_conflicts.py b/.github/scripts/case_conflicts.py new file mode 100755 index 000000000..83a2ef0c4 --- /dev/null +++ b/.github/scripts/case_conflicts.py @@ -0,0 +1,28 @@ +from collections import defaultdict +from glob import glob + +def main() -> None: + found_conflict = False + all_markdown_paths = glob("../../*.md") + glob("../../**/*.md") + + paths_by_lower_path = defaultdict(list) + for path in all_markdown_paths: + paths_by_lower_path[path.lower()].append(path) + + for lower_path, original_paths in paths_by_lower_path.items(): + #print(f"count={len(original_paths)} - {lower_path}") + if len(original_paths) == 1: + # No conflict. + continue + + found_conflict = True + print("Conflict!") + for path in original_paths: + print(f"\t{path}") + + if found_conflict: + exit(1) + +if __name__ == '__main__': + main() + From 75822c149bde645a9ce765c3d83e24f7677882d5 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 19 Dec 2022 13:37:10 -0500 Subject: [PATCH 2/3] Add case_conflicts.py to the update_hub add plugins/themes/authors script. This will prevent the addition of new files where the only difference between it and an existing file is the case of the filename. --- .github/workflows/update_hub.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update_hub.yml b/.github/workflows/update_hub.yml index df731162a..a733e4d56 100644 --- a/.github/workflows/update_hub.yml +++ b/.github/workflows/update_hub.yml @@ -45,6 +45,7 @@ jobs: run: | cd .github/scripts python3 ./update_releases.py --all + python3 ./case_conflicts.py cd ../.. git add . git commit -m "Add new plugins, themes and authors" || echo "nothing to commit" From fcde47b5faf1eb5351f9c34f91348854e878fa83 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 19 Dec 2022 13:39:13 -0500 Subject: [PATCH 3/3] Add the case_conflicts to the general content_check workflow. This should ensure human edits to files do not result in filenames that differ only in the case of the filename. --- .github/workflows/check_content.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/check_content.yml b/.github/workflows/check_content.yml index 647869492..f1f087858 100644 --- a/.github/workflows/check_content.yml +++ b/.github/workflows/check_content.yml @@ -42,3 +42,8 @@ jobs: run: | cd .github/scripts ./run_markdownlint.sh + + - name: Check that there are no files whose filename differs only by capitalization. + run: | + cd .github/scripts + python3 ./case_conflicts.py