Skip to content

Commit 9be7363

Browse files
committed
add script/changelog
1 parent 625674e commit 9be7363

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

README.rdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ To run the integration tests against an LDAP server:
5656
This section is for gem maintainers to cut a new version of the gem.
5757

5858
* Update lib/net/ldap/version.rb to next version number X.X.X following {semver}(http://semver.org/).
59-
* Update `History.rdoc`. Get latest changes with `git log --oneline vLAST_RELEASE..HEAD | grep Merge`
59+
* Update `History.rdoc`. Get latest changes with `script/changelog`
6060

6161
* On the master branch, run `script/release`
6262

script/changelog

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# Usage: script/changelog [-r <repo>] [-b <base>] [-h <head>]
3+
#
4+
# repo: BASE string of GitHub REPOsitory url. e.g. "user_or_org/REPOsitory". Defaults to git remote url.
5+
# base: git ref to compare from. e.g. "v1.3.1". Defaults to latest git tag.
6+
# head: git ref to compare to. Defaults to "HEAD".
7+
#
8+
# Generate a changelog preview from pull requests merged between `base` and
9+
# `head`.
10+
#
11+
# https://github.com/jch/release-scripts/blob/master/changelog
12+
set -e
13+
14+
[ $# -eq 0 ] && set -- --help
15+
while [[ $# > 1 ]]
16+
do
17+
key="$1"
18+
case $key in
19+
-r|--repo)
20+
repo="$2"
21+
shift
22+
;;
23+
-b|--base)
24+
base="$2"
25+
shift
26+
;;
27+
-h|--head)
28+
head="$2"
29+
shift
30+
;;
31+
*)
32+
;;
33+
esac
34+
shift
35+
done
36+
37+
repo="${repo:-$(git remote -v | grep push | awk '{print $2}' | cut -d'/' -f4- | sed 's/\.git//')}"
38+
base="${base:-$(git tag -l | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -n 1)}"
39+
head="${head:-HEAD}"
40+
api_url="https://api.github.com"
41+
42+
# get merged PR's. Better way is to query the API for these, but this is easier
43+
for pr in $(git log --oneline $base..$head | grep "Merge pull request" | awk '{gsub("#",""); print $5}')
44+
do
45+
# frustrated with trying to pull out the right values, fell back to ruby
46+
curl -s "$api_url/repos/$repo/pulls/$pr" | ruby -rjson -e 'pr=JSON.parse(STDIN.read); puts "* #{pr[%q(title)]} {##{pr[%q(number)]}}[#{pr[%q(html_url)]}]"'
47+
done

0 commit comments

Comments
 (0)