Skip to content

Commit

Permalink
Merge pull request #7296 from ipfs/feat/mkreleaselog-imp
Browse files Browse the repository at this point in the history
fix(mkreleasenotes): include commits directly to master
  • Loading branch information
Stebalien committed May 13, 2020
2 parents fa8c88b + d2b1d5b commit 8e7cead
Showing 1 changed file with 46 additions and 9 deletions.
55 changes: 46 additions & 9 deletions bin/mkreleaselog
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,30 @@ export GOPATH="$(go env GOPATH)"

alias jq="jq --unbuffered"

[[ -n "${REPO_FILTER+x}" ]] || REPO_FILTER="github.com/(ipfs|libp2p|ipld)"
[[ -n "${IGNORED_FILES+x}" ]] || IGNORED_FILES='^\(\.gx\|package.json\|\.travis.yml\|go.mod\|go.sum\)$'
AUTHORS=(
# orgs
ipfs
ipld
libp2p
multiformats
filecoin-project
ipfs-shipyard

# Authors of personal repos used by go-ipfs that should be mentioned in the
# release notes.
whyrusleeping
Kubuxu
jbenet
Stebalien
marten-seemann
hsanjuan
lucas-clemente
warpfork
)

[[ -n "${REPO_FILTER+x}" ]] || REPO_FILTER="github.com/(${$(printf "|%s" "${AUTHORS[@]}"):1})"

[[ -n "${IGNORED_FILES+x}" ]] || IGNORED_FILES='^\(\.gx\|package\.json\|\.travis\.yml\|go.mod\|go\.sum|\.github|\.circleci\)$'

NL=$'\n'

Expand Down Expand Up @@ -66,27 +88,42 @@ resolve_commits() {
jq '. + {Ref: (.Version|capture("^((?<ref1>.*)\\+incompatible|v.*-(0\\.)?[0-9]{14}-(?<ref2>[a-f0-9]{12})|(?<ref3>v.*))$") | .ref1 // .ref2 // .ref3)}'
}

pr_link() {
local repo="$1"
local prnum="$2"
local ghname="${repo##github.com/}"
printf -- "[%s#%s](https://%s/pull/%s)" "$ghname" "$prnum" "$repo" "$prnum"
}

# Generate a release log for a range of commits in a single repo.
release_log() {
setopt local_options BASH_REMATCH

local repo="$1"
local start="$2"
local end="${3:-HEAD}"
local ghname="${repo##github.com/}"
local dir="$GOPATH/src/$repo"

local commit prnum
local commit pr
git -C "$dir" log \
--format='tformat:%H %s' \
--merges \
--first-parent \
"$start..$end" |
sed -n -e 's/\([a-f0-9]\+\) .*#\([0-9]\+\).*/\1 \2/p' |
while read commit prnum; do
while read commit subject; do
# Skip gx-only PRs.
git -C "$dir" diff-tree --no-commit-id --name-only "$commit^" "$commit" |
grep -v "${IGNORED_FILES}" >/dev/null || continue

local desc="$(git -C "$dir" show --summary --format='tformat:%b' "$commit" | head -1)"
printf -- "- %s ([%s#%s](https://%s/pull/%s))\n" "$desc" "$ghname" "$prnum" "$repo" "$prnum"
if [[ "$subject" =~ '^Merge pull request #([0-9]+) from' ]]; then
local prnum="${BASH_REMATCH[2]}"
local desc="$(git -C "$dir" show --summary --format='tformat:%b' "$commit" | head -1)"
printf -- "- %s (%s)\n" "$desc" "$(pr_link "$repo" "$prnum")"
elif [[ "$subject" =~ '\(#([0-9]+)\)$' ]]; then
local prnum="${BASH_REMATCH[2]}"
printf -- "- %s (%s)\n" "$subject" "$(pr_link "$repo" "$prnum")"
else
printf -- "- %s\n" "$subject"
fi
done
}

Expand Down

0 comments on commit 8e7cead

Please sign in to comment.