Skip to content

Commit

Permalink
tools/generate-changelog.py: add a permalink in the changelog from wh…
Browse files Browse the repository at this point in the history
…ich the current build is sourced
  • Loading branch information
Meulengracht committed Aug 27, 2024
1 parent 86ab147 commit 3ff3baf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
TESTDIR ?= "prime/"
SNAP_NAME=core24
BUILDDIR=/build/$(SNAP_NAME)
REPO_URL=https://github.com/canonical/core-base

.PHONY: all
all: check
Expand Down Expand Up @@ -48,12 +49,14 @@ install:

# generate the changelog, for this we need the previous core snap
# to be installed, this should be handled in snapcraft.yaml
commit="$$(git rev-parse HEAD)"
if [ -e "/snap/$(SNAP_NAME)/current/usr/share/snappy/dpkg.yaml" ]; then \
./tools/generate-changelog.py \
"/snap/$(SNAP_NAME)/current/usr/share/snappy/dpkg.yaml" \
"$(DESTDIR)/usr/share/snappy/dpkg.yaml" \
"$(DESTDIR)/usr/share/doc" \
$(DESTDIR)/usr/share/doc/ChangeLog; \
"$(REPO_URL)/tree/$(commit)"
else \
echo "WARNING: changelog will not be generated for this build"; \
fi
Expand Down
7 changes: 6 additions & 1 deletion tools/generate-changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import gzip
import os
import requests
import subprocess
import sys
import yaml
from collections import namedtuple
Expand Down Expand Up @@ -175,13 +176,17 @@ def main():
parser.add_argument('new', metavar='new-manifest', help='Path to the manifest of the new snap')
parser.add_argument('docs', metavar='docs-dir', help='Path to the usr/share/doc directory in the rootfs of the new snap')
parser.add_argument('out', help='Optionally a path to where the changelog should be written')
parser.add_argument('permalink', help='Permalink to embed inside the changelog')
args = parser.parse_args()

old_manifest = args.old
new_manifest = args.new
docs_dir = args.docs

changes = '[ Changes in primed packages ]\n\n'
# add a header that helps us audit where the current build is
# sourced from.
changes = f"Built from commit {args.permalink}\n\n"
changes += '[ Changes in primed packages ]\n\n'
pkg_changes = compare_manifests(old_manifest, new_manifest, docs_dir)
if pkg_changes != '':
changes += pkg_changes
Expand Down

0 comments on commit 3ff3baf

Please sign in to comment.