Skip to content

Commit

Permalink
Add a case_conflict.py to check for case-only file conflicts.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andynu committed Dec 18, 2022
1 parent af33ac8 commit 5b54de2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/scripts/case_conflicts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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()

0 comments on commit 5b54de2

Please sign in to comment.