diff options
author | Daniel G. Taylor <danielgtaylor@gmail.com> | 2013-12-23 14:32:41 -0800 |
---|---|---|
committer | Daniel G. Taylor <danielgtaylor@gmail.com> | 2013-12-23 14:32:41 -0800 |
commit | 2ae586eaf7546e39fe4dc1435d043ebd92a38433 (patch) | |
tree | e679df499bc5914a6c47e504f0b162144e0affdf /scripts/git-release-notes.py | |
parent | 3c49e87c2729e532ba5714119bc7de06c6152371 (diff) | |
download | boto-2ae586eaf7546e39fe4dc1435d043ebd92a38433.tar.gz |
Add release notes script
Adds a script to find the latest release and gather all commits
from then until the latest commit, then spits out restructured
text.
Diffstat (limited to 'scripts/git-release-notes.py')
-rwxr-xr-x | scripts/git-release-notes.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/scripts/git-release-notes.py b/scripts/git-release-notes.py new file mode 100755 index 00000000..5e4c3acb --- /dev/null +++ b/scripts/git-release-notes.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import datetime +import re +import subprocess + +RELEASE = re.compile(r'[0-9]+\.[0-9]+\.[0-9]+') +ISSUE = re.compile(r'#([0-9]+)') +REVLIST = 'git rev-list develop --abbrev-commit --format="parents %p%n%B%n~~~" --max-count=200 develop' +TEMPLATE = """ +boto v{version} +=========== + +:date: {date} + +Description goes here. + + +Changes +------- +{changes} +""" + +revisions = subprocess.check_output(REVLIST, shell=True, stderr=subprocess.STDOUT) + +commit_list = [] +for hunk in revisions.split('~~~')[:-1]: + lines = hunk.strip().splitlines() + commit = lines[0].split(' ', 1)[1] + parents = lines[1].split(' ', 1)[1].split(' ') + message = ' '.join(lines[2:]) + + #print(commit, parents) + + if RELEASE.search(message): + print('Found release commit, stopping:') + print(message) + break + + if len(parents) > 1: + commit_list.append([commit, message]) + +removals = [ + re.compile(r'merge pull request #[0-9]+ from [a-z0-9/_-]+', re.I), + re.compile(r"merge branch '[a-z0-9/_-]+' into [a-z0-9/_-]+", re.I), + re.compile(r'fix(es)? [#0-9, ]+.?', re.I) +] + +changes = '' +for commit, message in commit_list: + append = [] + for issue in ISSUE.findall(message): + append.append(':issue:`{issue}`'.format(issue=issue)) + append.append(':sha:`{commit}`'.format(commit=commit)) + append = ' (' + ', '.join(append) + ')' + + original = message + for removal in removals: + message = removal.sub('', message) + + message = message.strip() + + if not message: + message = original.strip() + + changes += '* ' + message + append + '\n' + +print(TEMPLATE.format( + version='?.?.?', + date=datetime.datetime.now().strftime('%Y/%m/%d'), + changes=changes +)) |