mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 04:57:57 +01:00
[MIRROR] Improve validation script annotations [MDB IGNORE] (#15968)
* Improve validation script annotations (#69553) We now correctly calculate the offset into the DME file by comparing total lines in vs lines stored. Note this will fail if you ever skip lines in the middle of the file We also show the expected line instead * Improve validation script annotations Co-authored-by: oranges <email@oranges.net.nz>
This commit is contained in:
@@ -14,8 +14,9 @@ FORBID_INCLUDE = [
|
||||
]
|
||||
|
||||
lines = []
|
||||
|
||||
total = 0
|
||||
for line in sys.stdin:
|
||||
total+=1
|
||||
line = line.strip()
|
||||
|
||||
if line == "// BEGIN_INCLUDE":
|
||||
@@ -28,6 +29,8 @@ for line in sys.stdin:
|
||||
|
||||
lines.append(line)
|
||||
|
||||
offset = total - len(lines)
|
||||
print(f"{offset} lines were ignored in output")
|
||||
fail_no_include = False
|
||||
|
||||
code_files = glob.glob("code/**/*.dm", recursive=True) + glob.glob("modular_skyrat/**/*.dm", recursive=True) # SKYRAT EDIT CHANGE
|
||||
@@ -85,9 +88,8 @@ def compare_lines(a, b):
|
||||
raise f"Two lines were exactly the same ({a} vs. {b})"
|
||||
|
||||
sorted_lines = sorted(lines, key = functools.cmp_to_key(compare_lines))
|
||||
|
||||
for (index, line) in enumerate(lines):
|
||||
if sorted_lines[index] != line:
|
||||
print(f"The include at line {index + 1} is out of order ({line})")
|
||||
print(f"::error file=tgstation.dme,line={index+1},title=DME Validator::The include at line {index + 1} is out of order ({line})")
|
||||
print(f"The include at line {index + offset} is out of order ({line}, expected {sorted_lines[index]})")
|
||||
print(f"::error file=tgstation.dme,line={index+offset},title=DME Validator::The include at line {index + offset} is out of order ({line}, expected {sorted_lines[index]})")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user