[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:
SkyratBot
2022-09-02 21:55:52 +02:00
committed by GitHub
parent fc6188a6b5
commit dc0ca24d52
+6 -4
View File
@@ -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)