Skip to content
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
30 changes: 30 additions & 0 deletions build/gen_changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

COMMIT_RANGE="$1"

REPO=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
BASE_URL="https://github.com/$REPO/issues/"

if test -z "$1"; then
echo "This script builds changelog entries based on merge commits within the given range" >&2
echo "" >&2
echo "Usage $0 commit_range" >&2
echo "" >&2
echo "commit_range is \"commitid1..commitid2\", for example \"v10.0.2..stable20\"" >&2
exit 1
fi

# get all merge commits within the commit range
git log --merges "$COMMIT_RANGE" --format="format:%s - %b" |
# only pick the "pull request" ones in case of some bad merges
grep "pull request" |
# pick up PR id and subject
cut -d" " -f4,8- |
# move the PR id to the end of the row
sed -e "s&^\(#[0-9]*\) \(.*\)$&- \2 - \1&g" |
# replace PR id with Github links
sed -e "s& #\([0-9]*\)$& \[#\1\]\("$BASE_URL"\1\)&g" |
# remove "[stable10]" or other prefix strings
sed -e "s&\[stable[0-9]*\] &&gi"