Skip to content

Commit

Permalink
[MIRROR] Ensures our linter and dreammaker agree on file extension or…
Browse files Browse the repository at this point in the history
…dering [MDB IGNORE] (Skyrat-SS13#22598)

* Ensures our linter and dreammaker agree on file extension ordering (#76947)

## About The Pull Request

Dreammaker will sort files by folder, then extension, then name We
however lint only by folder and name, which leads to needing to play go
between manually. this is dumb. let's not be dumb

* Ensures our linter and dreammaker agree on file extension ordering

* Update tgstation.dme

* Update tgstation.dme (again?)

---------

Co-authored-by: LemonInTheDark <[email protected]>
Co-authored-by: lessthanthree <[email protected]>
Co-authored-by: Giz <[email protected]>
  • Loading branch information
4 people authored Jul 20, 2023
1 parent 9739a0a commit 2244a98
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tools/ticked_file_enforcement/ticked_file_enforcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ def compare_lines(a, b):
a = a[len("#include \""):-1].lower()
b = b[len("#include \""):-1].lower()

split_by_period = a.split('.')
a_suffix = ""
if len(split_by_period) >= 2:
a_suffix = split_by_period[len(split_by_period) - 1]
split_by_period = b.split('.')
b_suffix = ""
if len(split_by_period) >= 2:
b_suffix = split_by_period[len(split_by_period) - 1]

a_segments = a.split('\\')
b_segments = b.split('\\')

Expand All @@ -124,6 +133,10 @@ def compare_lines(a, b):

# interface\something.dm will ALWAYS come after code\something.dm
if a_segment != b_segment:
# if we're at the end of a compare, then this is about the file name
# files with longer suffixes come after ones with shorter ones
if a_suffix != b_suffix:
return (a_suffix > b_suffix) - (a_suffix < b_suffix)
return (a_segment > b_segment) - (a_segment < b_segment)

print(f"Two lines were exactly the same ({a} vs. {b})")
Expand Down

0 comments on commit 2244a98

Please sign in to comment.