forked from openlayers/openlayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangelog.sh
executable file
·76 lines (62 loc) · 2.04 KB
/
changelog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# Generate a Markdown-formatted changelog from merge commits.
#
set -o errexit
#
# Regex to match the standard pull request commit message. Creates capture
# groups for pull request number, GitHub username, and commit message body.
#
MERGE_RE=Merge\ pull\ request\ #\([0-9]+\)\ from\ \([^/]+\)\/[^\ ]+\ \(.*\)
#
# Regex to match the squash commit message. Creates capture groups for git
# author, commit subject and pull request number.
#
SQUASH_RE='([^\|]+)\|([^\(]+) \(#([0-9]+)\)'
GITHUB_URL=https://github.com
PULLS_URL=${GITHUB_URL}/openlayers/openlayers/pull
display_usage() {
cat <<-EOF
Usage: ${1} <revision range>
Creates a Markdown-formatted changelog given a revision range.
E.g.
${1} v3.0.0.. > changelog/v3.1.0.md
See git-log(1) for details on the revision range syntax.
EOF
}
#
# Scan the git log for merge commit messages and output Markdown. This only
# follows the first parent of merge commits to avoid merges within a topic
# branch (instead only showing merges to master).
#
main() {
git log --first-parent --format='%aN|%s %b' ${1} |
{
while read l; do
output="`[[ ${l} =~ "openlayers/greenkeeper" ]] && echo greenkeeper || echo main`_output"
if [[ ${l} =~ ${MERGE_RE} ]] ; then
number="${BASH_REMATCH[1]}"
author="${BASH_REMATCH[2]}"
summary="${BASH_REMATCH[3]}"
declare $output+=" * [#${number}](${PULLS_URL}/${number}) - ${summary} ([@${author}](${GITHUB_URL}/${author}))\n"
elif [[ ${l} =~ ${SQUASH_RE} ]] ; then
number="${BASH_REMATCH[3]}"
author="${BASH_REMATCH[1]}"
summary="${BASH_REMATCH[2]}"
declare $output+=" * [#${number}](${PULLS_URL}/${number}) - ${summary} ([${author}](${GITHUB_URL}/search?q=${author}&type=Users))\n"
fi
done
echo -e "$main_output"
if [ -n "$greenkeeper_output" ]; then
echo
echo "Additionally a number of updates where made to our dependencies:"
echo -e "$greenkeeper_output"
fi
}
}
if test ${#} -ne 1; then
display_usage ${0}
exit 1
else
main ${1}
fi