From 4ff9a851e683b14b150b5941fb28b988e17242e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= <76261501+zecakeh@users.noreply.github.com> Date: Wed, 5 Mar 2025 10:43:27 +0100 Subject: [PATCH] Add link to git commit for unstable changelog too (#2078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- changelogs/internal/newsfragments/2078.clarification | 1 + layouts/docs/changelog.html | 12 ++++++++++-- scripts/generate-changelog.sh | 12 +++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 changelogs/internal/newsfragments/2078.clarification diff --git a/changelogs/internal/newsfragments/2078.clarification b/changelogs/internal/newsfragments/2078.clarification new file mode 100644 index 00000000..d9285d5a --- /dev/null +++ b/changelogs/internal/newsfragments/2078.clarification @@ -0,0 +1 @@ +Add link to the git commit for the unstable changelog. diff --git a/layouts/docs/changelog.html b/layouts/docs/changelog.html index b23c8074..94fa55a3 100644 --- a/layouts/docs/changelog.html +++ b/layouts/docs/changelog.html @@ -31,9 +31,17 @@

{{ .Title }}

- {{ if ne $version "unstable" -}} - {{ $commitLink := printf "https://github.com/matrix-org/matrix-spec/tree/%s" $version -}} + {{ $rev := $version }} + {{ if eq $version "unstable" -}} + {{- /* + Extract the git SHA from the frontmatter of the changelog, where + it was stashed by `generate-changelog.sh`. + */ -}} + {{ $rev = .Params.commit -}} + {{ end -}} + {{ $commitLink := printf "https://github.com/matrix-org/matrix-spec/tree/%s" $rev -}} + {{ if ne $version "unstable" }} {{ end -}} {{ $checklist := .OutputFormats.Get "checklist" -}} diff --git a/scripts/generate-changelog.sh b/scripts/generate-changelog.sh index 678af60f..9c80b059 100755 --- a/scripts/generate-changelog.sh +++ b/scripts/generate-changelog.sh @@ -44,8 +44,18 @@ outputs: - html - checklist date: $(date -Idate) ---- EOF + + # Add the commit hash for the unstable versions. It is used to generate a + # link to the commit on the repository. + if [ "$VERSION" == "vUNSTABLE" ]; then + echo "params:" + echo " commit: $(git rev-parse --short HEAD)" + fi + + # Close the frontmatter. + echo "---" + # Remove trailing whitespace (such as our intentionally blank RST headings) sed -e "s/[ ]*$//" rendered.md } > ../content/changelog/$FILENAME
Git commit{{ $commitLink }}
Release date{{ .Date | time.Format ":date_long" }}