Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

releng: add hacky commit log generator #546

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions releng/make-commit-log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

cleanup() {
[ -f "${MASTER_COMMITS}" ] && rm "${MASTER_COMMITS}"
[ -f "${RELEASE_COMMITS}" ] && rm "${RELEASE_COMMITS}"
[ -n "${CUR_BRANCH}" ] && 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

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

trap cleanup EXIT INT TERM

MASTER_COMMITS="$( mktemp )"
RELEASE_COMMITS="$( mktemp )"

(
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}"