ignore repeating blocks of changes

This commit is contained in:
2026-08-08 02:55:30 +02:00
parent 64fda357ad
commit 9417f2baa1
11 changed files with 38 additions and 5900 deletions
+38 -3
View File
@@ -59,7 +59,21 @@ class Module(object):
o['file'] = file
o['version'] = vers
self.operations.append(o)
def operation_key(self, operation):
# kwargs are intentionally ignored for now.
# The key is only used to collapse repeated migration blocks;
# it is not intended to establish semantic equality.
return (
operation.get("phase"),
operation.get("operation"),
operation.get("object"),
tuple(operation.get("args", [])),
operation.get("condition"),
)
def block_key(self, operations):
return tuple(self.operation_key(op) for op in operations)
def write_data(self):
outfile = REPORTS / f"{self.name}.md"
@@ -68,19 +82,40 @@ class Module(object):
out.write(f"# {self.name}\n\n")
# iterate all classes
for c in sorted(self.classes):
classe = self.classes[c]
out.write(f"## Klasse {c}\n\n")
last_blocks = None
for k in sorted(self.versionen.keys()):
# iterate all Versions
for k in sorted(classe.keys()):
v = classe.get(k, None)
if not v:
continue
if last_blocks == None:
last_blocks = len(v) * [None,]
out.write(f"### {k}\n\n")
for m in v:
# iterate all files / occureces
for i, m in enumerate(v):
# repeating?
key = self.block_key(m["operations"])
old_block = last_blocks[i]
if key == old_block:
continue
elif old_block and key[:len(old_block)] == old_block:
m["operations"] = m['operations'][len(old_block):]
last_blocks[i] = key
out.write(f"file: {m['file']} : {m['line']}\n")
for op in m["operations"]: