Created
March 2, 2024 00:47
-
-
Save szhu/a4f05f6e3599b6451732de8bdc01edbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
verbose() { | |
echo $ "$@" >&2 | |
"$@" | |
} | |
COMPARISON="${1:-origin/prod...origin/main}" | |
OUT=".git/changelog.out.html" | |
true >"$OUT" | |
echo "<title>$COMPARISON</title>" >>"$OUT" | |
echo "<style>:root { font: 14px sans-serif; } </style>" >>"$OUT" | |
echo "<ul>" >>"$OUT" | |
out=$(verbose git log --merges --oneline "$COMPARISON") && echo "$out" | while read line; do | |
PR_NUMBER=$(sed -n 's/.*Merge pull request #\([0-9]*\).*/\1/p' <<<"$line") | |
verbose gh pr view "$PR_NUMBER" --json title,number,url | | |
node -e 'x = JSON.parse(require("fs").readFileSync(0, "utf-8")); console.log(`<li><a href="${x.url}">${x.title.replace(/&/g, `&`).replace(/</g, `<`)} #${x.number}</a></li>`)' >>"$OUT" | |
done | |
test $? -eq 0 || exit 1 | |
echo "</ul>" >>"$OUT" | |
echo "Changelog generated: $OUT" | |
if command -v xdg-open &>/dev/null; then | |
xdg-open "$OUT" | |
elif command -v open &>/dev/null; then | |
open "$OUT" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment