-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrelease-notes
executable file
·151 lines (135 loc) · 3.64 KB
/
release-notes
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env bash
set -euo pipefail
SUPPORT_FIRECLOUD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
source ${SUPPORT_FIRECLOUD_DIR}/sh/common.inc.sh
#- release-notes 1.0
## Usage: release-notes [OPTION]
## Generate release notes from a git commit range.
##
## --pkg-name The package name.
## --pkg-vsn The package version.
## Defaults to the tag/commit of of the end of the git commit rage.
## --from The beginning of the git commit range.
## Defaults to the latest version tag in the range.
## --to The end of the git commit range.
## Defaults to HEAD.
## --pattern The version pattern to filter tags by.
## Defaults to "^v"
##
## -h, --help Display this help and exit
## -v, --version Output version information and exit
FIRST_COMMIT=$(git rev-list --max-parents=0 HEAD | tail -1)
PKG_NAME=
PKG_VSN=
RANGE_FROM=
RANGE_TO=HEAD
VERSION_PATTERN="^v"
if { getopt --test >/dev/null 2>&1 && false; } || [[ "$?" = "4" ]] || false; then
ARGS=$(getopt -o hv -l help,version,pkg-name:,pkg-vsn:,from:,to:,pattern: -n $(basename ${BASH_SOURCE[0]}) -- "$@") || sh_script_usage # editorconfig-checker-disable-line
eval set -- "${ARGS}"
fi
while [[ $# -gt 0 ]]; do
case "$1" in
--pkg-name)
PKG_NAME=$2
shift 2
;;
--pkg-vsn)
PKG_VSN=$2
shift 2
;;
--from)
RANGE_FROM=$2
shift 2
;;
--to)
RANGE_TO=$2
shift 2
;;
--pattern)
VERSION_PATTERN=$2
shift 2
;;
-h|--help)
sh_script_usage
;;
-v|--version)
sh_script_version
;;
--)
shift
break
;;
-*)
sh_script_usage
;;
*)
break
;;
esac
done
[[ $# -eq 0 ]] || sh_script_usage
# RANGE_FROM_VSN=$(git tag --points-at ${RANGE_FROM:-${FIRST_COMMIT}} | { grep -e "${VERSION_PATTERN}" || true; })
RANGE_TO_VSN=$(git tag --points-at ${RANGE_TO} | { grep "${VERSION_PATTERN}" || true; })
PKG_VSN=${PKG_VSN:-${RANGE_TO_VSN}}
if [[ -z "${RANGE_FROM}" ]]; then
PREV_VSNS="$(git log --simplify-by-decoration --format=%H ${FIRST_COMMIT}..${RANGE_TO}~ |
while read -r NO_XARGS_R; do [[ -n "${NO_XARGS_R}" ]] || continue; git tag --points-at "${NO_XARGS_R}"; done |
{ grep "${VERSION_PATTERN}" || true; } |
sort -V |
tac)"
if [[ -n "${PREV_VSNS}" ]]; then
RANGE_FROM=$(echo "${PREV_VSNS}" | head -1)
else
RANGE_FROM=${FIRST_COMMIT}
fi
fi
echo "${PKG_NAME} ${PKG_VSN:-${RANGE_TO}} Release Notes"
echo
if [[ -z "${RANGE_FROM}" ]]; then
echo "Highlights:"
else
echo "Highlights since ${RANGE_FROM}:"
fi
echo
echo "* None"
echo
echo
if [[ -z "${RANGE_FROM}" ]]; then
echo "Breaking commits:"
else
echo "Breaking commits since ${RANGE_FROM}:"
fi
echo
git --no-pager log \
--date=short \
--graph \
--no-decorate \
--pretty=format:"%h %ad %s" \
--boundary \
--no-color \
${RANGE_FROM:-${FIRST_COMMIT}}..${RANGE_TO} | \
sed "s/^ /./" | \
sed "s/ *$//" | \
grep "break" || \
echo -n "* None"
echo
echo
if [[ -z "${RANGE_FROM}" ]]; then
echo "Commits:"
else
echo "Commits since ${RANGE_FROM}:"
fi
echo
git --no-pager log \
--date=short \
--graph \
--no-decorate \
--pretty=format:"%h %ad %s" \
--boundary \
--no-color \
${RANGE_FROM:-${FIRST_COMMIT}}..${RANGE_TO} | \
sed "s/^ /./" | \
sed "s/ *$//" || \
echo -n "* None"
echo