public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH 06/12] fedora: Introduce own rpkg macro for changelog
Date: Thu, 18 Aug 2022 22:22:29 +0200	[thread overview]
Message-ID: <20220818202235.1591828-7-sbrivio@redhat.com> (raw)
In-Reply-To: <20220818202235.1591828-1-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2962 bytes --]

git_dir_changelog is useful in theory, but it requires pairs of
annotated tags, which should be generated by rpkg itself to make any
sense, implying a relatively heavyweight interaction whenever I want
to push a new package version.

Also, the default content of the changelog entries include the full
list of changes, but the Fedora Packaging Guidelines specifically
mention that:

  [t]hey must never simply contain an entire copy of the source
  CHANGELOG entries.

We don't have a CHANGELOG file, but the full git history is
conceptually equivalent for this purpose, I guess.

Introduce our own passt_git_changelog() rpkg macro, building
changelog entries, using tags in the form DATE-SHA, where DATE
is an ISO 8601 date representation, and SHA is a short (7-digits)
form of the head commit at a given moment (git push).

These changelog entries mention, specifically, changes to the
packaging information itself (entries under contrib/fedora), and
simply report a link to cgit for the ranges between tags.

Reported-by: Benson Muite <benson_muite(a)emailplus.org>
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
 contrib/fedora/passt.spec  |  2 +-
 contrib/fedora/rpkg.macros | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/contrib/fedora/passt.spec b/contrib/fedora/passt.spec
index 8ae104a..41e4e3a 100644
--- a/contrib/fedora/passt.spec
+++ b/contrib/fedora/passt.spec
@@ -93,4 +93,4 @@ semodule -r pasta 2>/dev/null || :
 %{_datadir}/selinux/packages/%{name}/pasta.pp
 
 %changelog
-{{{ git_dir_changelog }}}
+{{{ passt_git_changelog }}}
diff --git a/contrib/fedora/rpkg.macros b/contrib/fedora/rpkg.macros
index 9e0cd78..c9ba03d 100644
--- a/contrib/fedora/rpkg.macros
+++ b/contrib/fedora/rpkg.macros
@@ -14,3 +14,37 @@
 function git_version {
 	printf "0.git.%s.%s" "$(date -u -I | tr - _)" "$(git rev-parse --short HEAD)"
 }
+
+function passt_git_changelog_entry {
+	__from="${2}"
+	__to="${1}"
+
+	[ -z "${__from}" ] && __from="$(git rev-list --max-parents=0 HEAD)"
+
+	__date="$(git log --pretty="format:%cI" "${__to}" -1)"
+	__author="$(git log -1 --pretty="format:%an <%ae>" ${__to} -- contrib/fedora)"
+
+	printf "* %s %s - %s\n" "$(date "+%a %b %e %Y" -d "${__date}")" "${__author}" "0.git.${1}-0"
+
+	IFS='
+'
+	for l in $(git log ${__from}..${__to} --pretty=format:"- %s" -- contrib/fedora); do
+		printf "%s%s\n" '-' "${l#*:}"
+	done
+	unset IFS
+
+	printf "%s Upstream changes: https://passt.top/passt/log/?qt=range&q=%s..%s\n\n" '-' "${__from}" "${__to}"
+}
+
+function passt_git_changelog_pairs {
+	while [ -n "${2}" ]; do
+		passt_git_changelog_entry "${1}" "${2}"
+		shift 2
+	done
+
+	passt_git_changelog_entry "${1}" ""
+}
+
+function passt_git_changelog {
+	passt_git_changelog_pairs $((git tag --sort="-v:refname"|tail -n+2; git tag --sort="-v:refname") | sort -r)
+}
-- 
@@ -14,3 +14,37 @@
 function git_version {
 	printf "0.git.%s.%s" "$(date -u -I | tr - _)" "$(git rev-parse --short HEAD)"
 }
+
+function passt_git_changelog_entry {
+	__from="${2}"
+	__to="${1}"
+
+	[ -z "${__from}" ] && __from="$(git rev-list --max-parents=0 HEAD)"
+
+	__date="$(git log --pretty="format:%cI" "${__to}" -1)"
+	__author="$(git log -1 --pretty="format:%an <%ae>" ${__to} -- contrib/fedora)"
+
+	printf "* %s %s - %s\n" "$(date "+%a %b %e %Y" -d "${__date}")" "${__author}" "0.git.${1}-0"
+
+	IFS='
+'
+	for l in $(git log ${__from}..${__to} --pretty=format:"- %s" -- contrib/fedora); do
+		printf "%s%s\n" '-' "${l#*:}"
+	done
+	unset IFS
+
+	printf "%s Upstream changes: https://passt.top/passt/log/?qt=range&q=%s..%s\n\n" '-' "${__from}" "${__to}"
+}
+
+function passt_git_changelog_pairs {
+	while [ -n "${2}" ]; do
+		passt_git_changelog_entry "${1}" "${2}"
+		shift 2
+	done
+
+	passt_git_changelog_entry "${1}" ""
+}
+
+function passt_git_changelog {
+	passt_git_changelog_pairs $((git tag --sort="-v:refname"|tail -n+2; git tag --sort="-v:refname") | sort -r)
+}
-- 
2.35.1


  parent reply	other threads:[~2022-08-18 20:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 20:22 [PATCH 00/12] Updates and fixes for documentation and Fedora package Stefano Brivio
2022-08-18 20:22 ` [PATCH 01/12] doc: Rewrite demo script Stefano Brivio
2022-08-18 20:22 ` [PATCH 02/12] README: Add link to Copr repositories Stefano Brivio
2022-08-18 20:22 ` [PATCH 03/12] Makefile: Ugly hack to get a "plain" Markdown version of README Stefano Brivio
2022-08-18 20:22 ` [PATCH 04/12] Makefile: Install demo.sh too, uninstall stuff under /usr/share Stefano Brivio
2022-08-18 20:22 ` [PATCH 05/12] fedora: Install "plain" README, instead of web version, and demo script Stefano Brivio
2022-08-18 20:22 ` Stefano Brivio [this message]
2022-08-18 20:22 ` [PATCH 07/12] fedora: Start Release tag from 1, not 0 Stefano Brivio
2022-08-18 20:22 ` [PATCH 08/12] fedora: Drop VCS tag from spec file Stefano Brivio
2022-08-18 20:22 ` [PATCH 09/12] fedora: Change source URL to HEAD link with explicit commit SHA Stefano Brivio
2022-08-18 20:22 ` [PATCH 10/12] fedora: Build SELinux subpackage as noarch Stefano Brivio
2022-08-18 20:22 ` [PATCH 11/12] fedora: Don't hardcode CFLAGS setting, use %set_build_flags macro instead Stefano Brivio
2022-08-18 20:22 ` [PATCH 12/12] fedora: Fix man pages wildcards in spec file Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220818202235.1591828-7-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).