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