diff options
| author | Agando <roduccomm@gmail.com> | 2026-11-06 11:40:54 +0100 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-11-06 11:40:54 +0100 |
| commit | 7bdcd58762c60c9501657b9df2983999f276f8b1 (patch) | |
| tree | 0b6f23e78869a50b2fb5a1cb4d4e535872474c05 /scripts/build-changelog.py | |
| parent | 1983ce5796e45b312b142554cb717db7f8978bc8 (diff) | |
fix(changelog): keep the newest commits of a build; wrap long detail URLs
Symptom: after bodies were rendered, this fix's own commit was missing from
its own entry, and a long URL inside an expanded detail was clipped at the
right edge on a 390 px screen.
Cause: items took group[:MAX_ITEMS] from a CHRONOLOGICAL list, so a 17-commit
build showed its first 14 and dropped the newest three (the count line said
"…and 3 more", hiding which three). And the injected detail CSS set no
overflow-wrap, so a 47-character URL pushed the paragraph to 320 px of
unbreakable text — the document stayed at 0 overflow only because the li
clipped it.
Fix: show group[-MAX_ITEMS:] and label the omitted ones "…and N earlier
commit(s)"; entry.commits follows the same slice. overflow-wrap:anywhere on
detail p/ul. The CSS block is now re-emitted from DETAIL_CSS behind
BEGIN/END sentinels instead of being write-once, and the first version's
sentinel-less block is stripped on sight so no page keeps two copies.
Verified: 390 px — p scrollWidth == clientWidth == 320, document overflow 0,
URL wraps; newest entry lists c759c50 and this commit; island 83 entries,
14 commit chips matching 14 shown items; CHANGELOG.md byte-identical on a
second run.
Diffstat (limited to 'scripts/build-changelog.py')
| -rw-r--r-- | scripts/build-changelog.py | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/scripts/build-changelog.py b/scripts/build-changelog.py index 29d8e83..391581b 100644 --- a/scripts/build-changelog.py +++ b/scripts/build-changelog.py @@ -268,12 +268,16 @@ def build(): entries = [] for ver, group in releases.items(): items = [] - for row in group[:MAX_ITEMS]: + # The NEWEST commits of a build, not the oldest: group is chronological, so group[:N] + # showed the beginning of a 17-commit build and dropped the fixes that shipped last — + # measured 2026-11-06 when this fix's own commit was cut off its own entry. + shown = group[-MAX_ITEMS:] + if len(group) > MAX_ITEMS: + items.append('…and %d earlier commit(s) in this build' % (len(group) - MAX_ITEMS)) + for row in shown: items.append('<strong>%s</strong> <code>%s</code>%s' % ( clean(row['subject']), html.escape(row['sha'][:7]), detail_html(detail_blocks(row.get('body'))))) - if len(group) > MAX_ITEMS: - items.append('…and %d more commit(s) in this build' % (len(group) - MAX_ITEMS)) kinds = Counter(kind_of(r['subject']) for r in group) # The dominant kind makes the chip honest: a build that was 9 fixes and 1 # feature is a fix build, not a feature release. @@ -290,7 +294,7 @@ def build(): 'note': 'Touches ' + ', '.join('%s (%d)' % (a, n) for a, n in areas.most_common(4)) + ' · ' + ', '.join('%s %d' % (k, n) for k, n in kinds.most_common(3)), 'sources': sorted({f for r in group for f in r['files'][:1]})[:4], - 'commits': [r['sha'][:7] for r in group[:MAX_ITEMS]], + 'commits': [r['sha'][:7] for r in shown], }) entries.reverse() # newest build first @@ -364,16 +368,22 @@ def existing_island(): # Rendered as native <details> inside each list item, so the page's own JS needs no change. # Injected once (sentinel-guarded) because the page is a static document: a builder that only # rewrites its JSON island cannot restyle anything else. -DETAIL_CSS = """ /* wx11-changelog-detail: collapsible commit body */ +DETAIL_CSS = """ /* wx11-changelog-detail:BEGIN */ .entry li>details{margin:.3rem 0 0} .entry li>details>summary{ - cursor:pointer; font-family:var(--mono); font-size:.66rem; letter-spacing:.08em; - text-transform:uppercase; color:var(--ink-3); padding:.15rem 0; + cursor:pointer; font-family:var(--mono); font-size:.7rem; letter-spacing:.08em; + text-transform:uppercase; color:var(--ink-3); padding:.45rem 0; } .entry li>details>summary:hover{color:var(--cyan)} - .entry li>details p{margin:.35rem 0 0; font-size:.88rem; color:var(--ink-2); line-height:1.55} - .entry li>details ul{margin:.3rem 0 0; padding-left:1rem; font-size:.88rem; color:var(--ink-2); line-height:1.55} + .entry li>details p{margin:.35rem 0 0; font-size:.88rem; color:var(--ink-2); line-height:1.55; overflow-wrap:anywhere} + .entry li>details ul{margin:.3rem 0 0; padding-left:1rem; font-size:.88rem; color:var(--ink-2); line-height:1.55; overflow-wrap:anywhere} + /* wx11-changelog-detail:END */ """ +DETAIL_CSS_RX = re.compile(r'/\* wx11-changelog-detail:BEGIN \*/[\s\S]*?/\* wx11-changelog-detail:END \*/\n?') +# The first version shipped a single-line sentinel and no end marker; strip it or the page +# would keep both copies forever. +LEGACY_CSS_RX = re.compile(r'\s*/\* wx11-changelog-detail: collapsible commit body \*/' + r'[\s\S]*?\.entry li>details ul\{[^}]*\}\n') def write_page(page): @@ -390,7 +400,12 @@ def write_page(page): new = re.sub(r'(<section class="panel" aria-labelledby="gaps-h">[\s\S]*?<h2 id="gaps-h">[^<]*</h2>\s*<p>)[\s\S]*?(</p>)', lambda m: m.group(1) + GAP_INTRO + m.group(2), new, count=1) new = re.sub(r'(<b id="cur-ver">)[^<]*(</b>)', lambda m: m.group(1) + html.escape(page['currentVersion']) + m.group(2), new, count=1) - if '/* wx11-changelog-detail' not in new: + new = LEGACY_CSS_RX.sub('\n', new, count=1) + if DETAIL_CSS_RX.search(new): + # Owned block: re-emitted every run, so the rules can be edited here (the page is + # static; a stale copy on disk would silently win). + new = DETAIL_CSS_RX.sub(lambda m: DETAIL_CSS, new, count=1) + else: new, n = re.subn(r'(\n\s*</style>)', lambda m: '\n' + DETAIL_CSS + m.group(1), new, count=1) assert n == 1, 'no </style> to inject the detail CSS before - page layout changed' write_atomic(PAGE, new) |