Files
vhaudiquet 5bf262b82b app: cherry-pick rune's pause and sound fixes onto the checkout
Rune comes from app/vendor/rune now, a checkout of 63ad0209 on branch
ported, carrying the four commits of upstream issues 1320 (a pause while
a clip is layered holds the layer's picture and time) and 1325 (a video's
sound is read ahead of the clock and leads it). Both were written against
eb9f1104 and ported across the refactors since. The faults are the first
two and the third in docs/rune-upstream.md; the app's workarounds in
review.rs stay until the fixes arrive upstream.
2026-11-22 22:16:30 +01:00

53 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Fold changelog/unreleased/*.md into CHANGELOG.md under `## dev`, newest first, then delete them.
Usage: scripts/changelog-fold [--check]
Order is each fragment's first-commit time (git log --diff-filter=A), else the date in its filename.
"""
import calendar, glob, os, re, subprocess, sys, time
root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip()
os.chdir(root)
check = "--check" in sys.argv[1:]
def stamp(path):
out = subprocess.run(
["git", "log", "--diff-filter=A", "--format=%ct", "-1", "--", path],
capture_output=True, text=True,
).stdout.strip()
if out:
return int(out)
m = re.match(r"(\d{4})-(\d{2})-(\d{2})", os.path.basename(path))
return calendar.timegm((int(m[1]), int(m[2]), int(m[3]), 0, 0, 0)) if m else int(time.time())
frags = [f for f in glob.glob("changelog/unreleased/*.md") if os.path.basename(f) != "README.md"]
if not frags:
print("no fragments")
sys.exit(0)
frags.sort(key=lambda f: (-stamp(f), os.path.basename(f)))
entries = [open(f).read().strip("\n") for f in frags]
text = open("CHANGELOG.md").read()
lines = text.split("\n")
i = lines.index("## dev")
j = i + 1
while j < len(lines) and lines[j].strip() == "":
j += 1
# keep the note line (and any other leading prose) above the entries
while j < len(lines) and lines[j] and not lines[j].startswith(("- ", "## ")):
j += 1
while j < len(lines) and lines[j].strip() == "":
j += 1
block = "\n\n".join(entries).split("\n") + [""]
new = lines[:j] + block + lines[j:]
if check:
for f in frags:
print("would fold", f)
sys.exit(0)
open("CHANGELOG.md", "w").write("\n".join(new))
for f in frags:
os.remove(f)
print("folded", f)