mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-28 16:58:41 +01:00
The App Store "What's New" reused the 500-byte Play file, so long changelog entries were cut mid-word (7.0.0 ended in "...as an indoor cy"). head -c also counted bytes, cutting multi-byte text earlier and able to split a character. - scripts/truncate_release_notes.sh: truncate by Unicode characters; if the text must be cut, cut at the last line break (else last space) and append "…". Input that fits is passed through unchanged. - build.yml: Play keeps a <=500-char whatsnew; a separate <=4000-char store_notes/app_store_release_notes.txt feeds the iOS and macOS pushes. - Fastfile: push release notes to every listing locale, derived from the locale folders under the metadata dir (fallback list incl. es-MX), so es-MX no longer keeps the previous version's note. Screenshots are unchanged. - scripts/test_truncate_release_notes.sh covers the truncation rules. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
41 lines
1.2 KiB
Bash
Executable File
41 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Truncate release notes (stdin -> stdout) to at most <max_chars> Unicode
|
|
# characters — not bytes, so multi-byte characters like "•" or "—" count once
|
|
# and are never split.
|
|
#
|
|
# Input that fits is passed through unchanged. Otherwise the text is cut at the
|
|
# last line break that fits (falling back to the last space) and "…" is
|
|
# appended, so the store never shows half a word or URL.
|
|
#
|
|
# Usage: ./scripts/get_latest_changelog.sh | ./scripts/truncate_release_notes.sh 500
|
|
set -euo pipefail
|
|
|
|
if [ $# -ne 1 ] || ! [[ "$1" =~ ^[0-9]+$ ]] || [ "$1" -lt 2 ]; then
|
|
echo "Usage: $0 <max_chars> (>= 2) < input" >&2
|
|
exit 2
|
|
fi
|
|
|
|
exec python3 -c '
|
|
import sys
|
|
|
|
limit = int(sys.argv[1])
|
|
text = sys.stdin.buffer.read().decode("utf-8")
|
|
|
|
if len(text) <= limit:
|
|
sys.stdout.buffer.write(text.encode("utf-8"))
|
|
sys.exit(0)
|
|
|
|
# Last line break leaving room for "\n…".
|
|
idx = text.rfind("\n", 0, limit - 1)
|
|
cut = text[:idx].rstrip() if idx > 0 else ""
|
|
if cut:
|
|
out = cut + "\n…"
|
|
else:
|
|
# Last space leaving room for "…".
|
|
idx = text.rfind(" ", 0, limit)
|
|
cut = text[:idx].rstrip() if idx > 0 else ""
|
|
out = (cut if cut else text[:limit - 1]) + "…"
|
|
|
|
sys.stdout.buffer.write(out.encode("utf-8"))
|
|
' "$1"
|