Martin Hořeňovský | 8115983 | 2017-01-20 12:28:40 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
Phil Nash | 18845da | 2014-04-25 06:10:50 +0100 | [diff] [blame] | 3 | import os |
Phil Nash | 57374a1 | 2014-04-26 08:34:24 +0100 | [diff] [blame] | 4 | import re |
| 5 | import urllib2 |
| 6 | import json |
Phil Nash | 18845da | 2014-04-25 06:10:50 +0100 | [diff] [blame] | 7 | |
| 8 | from scriptCommon import catchPath |
| 9 | from scriptCommon import runAndCapture |
| 10 | |
Phil Nash | 57374a1 | 2014-04-26 08:34:24 +0100 | [diff] [blame] | 11 | issueNumberRe = re.compile( r'(.*?)#([0-9]*)([^0-9]?.*)' ) |
| 12 | |
Phil Nash | 18845da | 2014-04-25 06:10:50 +0100 | [diff] [blame] | 13 | rootPath = os.path.join( catchPath, 'include/' ) |
| 14 | versionPath = os.path.join( rootPath, "internal/catch_version.hpp" ) |
| 15 | |
| 16 | |
| 17 | hashes = runAndCapture( ['git', 'log', '-2', '--format="%H"', versionPath] ) |
| 18 | lines = runAndCapture( ['git', 'log', hashes[1] + ".." + hashes[0], catchPath] ) |
| 19 | |
| 20 | prevLine = "" |
| 21 | messages = [] |
| 22 | dates = [] |
Phil Nash | 57374a1 | 2014-04-26 08:34:24 +0100 | [diff] [blame] | 23 | issues = {} |
| 24 | |
| 25 | def getIssueTitle( issueNumber ): |
| 26 | try: |
| 27 | s = urllib2.urlopen("https://api.github.com/repos/philsquared/catch/issues/" + issueNumber ).read() |
Phil Nash | ad94288 | 2017-02-23 08:10:37 +0000 | [diff] [blame] | 28 | except: |
Phil Nash | 57374a1 | 2014-04-26 08:34:24 +0100 | [diff] [blame] | 29 | return "#HTTP Error#" |
| 30 | |
| 31 | try: |
| 32 | j = json.loads( s ) |
| 33 | return j["title"] |
Phil Nash | ad94288 | 2017-02-23 08:10:37 +0000 | [diff] [blame] | 34 | except: |
Phil Nash | 57374a1 | 2014-04-26 08:34:24 +0100 | [diff] [blame] | 35 | return "#JSON Error#" |
| 36 | |
Phil Nash | 18845da | 2014-04-25 06:10:50 +0100 | [diff] [blame] | 37 | for line in lines: |
| 38 | if line.startswith( "commit"): |
| 39 | pass |
| 40 | elif line.startswith( "Author:"): |
| 41 | pass |
| 42 | elif line.startswith( "Date:"): |
| 43 | dates.append( line[5:].lstrip() ) |
| 44 | pass |
| 45 | elif line == "" and prevLine == "": |
| 46 | pass |
| 47 | else: |
Phil Nash | 18845da | 2014-04-25 06:10:50 +0100 | [diff] [blame] | 48 | prevLine = line |
Phil Nash | 57374a1 | 2014-04-26 08:34:24 +0100 | [diff] [blame] | 49 | match = issueNumberRe.match( line ) |
| 50 | line2 = "" |
| 51 | while match: |
| 52 | issueNumber = match.group(2) |
| 53 | issue = '#{0} ("{1}")'.format( issueNumber, getIssueTitle( issueNumber ) ) |
| 54 | line2 = line2 + match.group(1) + issue |
| 55 | match = issueNumberRe.match( match.group(3) ) |
| 56 | if line2 == "": |
| 57 | messages.append( line ) |
| 58 | else: |
| 59 | messages.append( line2 ) |
Phil Nash | 18845da | 2014-04-25 06:10:50 +0100 | [diff] [blame] | 60 | |
| 61 | print "All changes between {0} and {1}:\n".format( dates[-1], dates[0] ) |
| 62 | |
| 63 | for line in messages: |
| 64 | print line |