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

fix(mkreleasenotes): include commits directly to master #7296

Merged
merged 2 commits into from
May 13, 2020
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
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)"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not everybody has go-ipfs pulled down as an actual dep

Suggested change
! [[ -d "$GOPATH/src/github.com/ipfs/go-ipfs" ]] \
&& echo 'You must leave the current repository dir and `go get -v github.com/ipfs/go-ipfs` before using this script' \
&& exit 1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this script assumes you're using a GOPATH and won't work without it, unfortunately.

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