From 0f9d52d9d892f785e500856262d05459e5f5bd25 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Sat, 21 Nov 2026 14:53:45 -0500 Subject: [PATCH] fix: don't write an empty changelog when the clone has one tag - git2debcl writes one entry per tag, listing the commits since the next older tag. With only one tag in the clone, or none, there was nothing to compare against and the changelog came out empty. - In that case list the whole history under the newest version. Output for clones with more than one tag is unchanged. --- buildtools/git2debcl | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/buildtools/git2debcl b/buildtools/git2debcl index 64ff2083..b22d3784 100755 --- a/buildtools/git2debcl +++ b/buildtools/git2debcl @@ -152,6 +152,23 @@ else echo "$TAGS" >> "$TMPFILE" fi +# Print one changelog entry: header, log lines, then author and time +print_entry() { + local tag="$1" + local ref="$2" + local entries="$3" + + printf "%s (%s%s) %s; urgency=%s\n\n" "$NAME" "$tag" "$VERSUFFIX" "$CODENAME" "$URGENCY" + + echo "$entries" | while IFS= read -r entry; do + if [ -n "$entry" ]; then + printf " * %s\n" "$entry" + fi + done + + printf "\n %s\n\n" "$(git_author_and_time "$ref")" +} + # Process tags and generate changelog PREV_TAG="" PREV_REF="" @@ -182,21 +199,17 @@ while IFS= read -r line; do continue fi - # Print package header - printf "%s (%s%s) %s; urgency=%s\n\n" "$NAME" "$PREV_TAG" "$VERSUFFIX" "$CODENAME" "$URGENCY" - - # Print each log entry - echo "$LOG_ENTRIES" | while IFS= read -r entry; do - if [ -n "$entry" ]; then - printf " * %s\n" "$entry" - fi - done - - # Print author and time - AUTHOR_TIME=$(git_author_and_time "$PREV_REF") - printf "\n %s\n\n" "$AUTHOR_TIME" + print_entry "$PREV_TAG" "$PREV_REF" "$LOG_ENTRIES" + FIRST=0 fi PREV_TAG="$TAG" PREV_REF="$REF" done < "$TMPFILE" + +# Each entry needs an older tag to compare against. A clone with only +# one tag, or none, would get an empty changelog, so list the whole +# history under the newest version instead. +if [ "$FIRST" = 1 ] && [ -n "$PREV_TAG" ]; then + print_entry "$PREV_TAG" "$PREV_REF" "$(git log --no-merges --oneline "$PREV_REF" 2>/dev/null)" +fi