Skip to content

Commit

Permalink
releng: add hacky commit log generator
Browse files Browse the repository at this point in the history
  • Loading branch information
zdykstra committed Dec 5, 2023
1 parent 54e41a2 commit 2d81c79
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions releng/make-commit-log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

cleanup() {
[ -f "${MASTER_COMMITS}" ] && rm "${MASTER_COMMITS}"
[ -f "${RELEASE_COMMITS}" ] && rm "${RELEASE_COMMITS}"
git checkout "${CUR_BRANCH}"
}

usage() {
cat <<-EOF
Usage: $0 [OPTIONS]
OPTIONS
-m <master branch>
Set the master branch, otherwise default to 'master'
-r <release branch>
Set the release tracking branch
-t <common tag>
Set the tag where commits diverged
-h Show this message and exit
EOF
exit
}

MASTER="master"
RELEASE=
TAG=

while getopts "m:r:t:h" opt; do
case "${opt}" in
m)
MASTER="${OPTARG}"
;;
r)
RELEASE="${OPTARG}"
;;
t)
TAG="${OPTARG}"
;;
h|*)
usage
;;
esac
done

[ -z "${RELEASE}" ] && usage
[ -z "${TAG}" ] && usage

trap cleanup EXIT INT TERM

MASTER_COMMITS="$( mktemp )"
RELEASE_COMMITS="$( mktemp )"
CUR_BRANCH="$( git rev-parse --abbrev-ref HEAD )"

(
git checkout "${MASTER}" && git log --format="%h;%s (%an)" "${TAG}..HEAD" > "${MASTER_COMMITS}"
git checkout "${RELEASE}" && git log --format="%h;%s (%an)" "${TAG}..HEAD" > "${RELEASE_COMMITS}"
git checkout "${CUR_BRANCH}"
) >/dev/null 2>&1

while IFS=';' read -r sha message; do
if grep -q "${message}" "${RELEASE_COMMITS}" ; then
continue
else
echo "* ${sha} ${message}"
fi
done < "${MASTER_COMMITS}"

0 comments on commit 2d81c79

Please sign in to comment.