blob: 80fffbf24d9f3f75246d3a213d8fc410b2028a9b [file] [log] [blame]
Martin Hořeňovský81159832017-01-20 12:28:40 +01001#!/usr/bin/env python
2
Phil Nash18845da2014-04-25 06:10:50 +01003import os
Phil Nash57374a12014-04-26 08:34:24 +01004import re
5import urllib2
6import json
Phil Nash18845da2014-04-25 06:10:50 +01007
8from scriptCommon import catchPath
9from scriptCommon import runAndCapture
10
Phil Nash57374a12014-04-26 08:34:24 +010011issueNumberRe = re.compile( r'(.*?)#([0-9]*)([^0-9]?.*)' )
12
Phil Nash18845da2014-04-25 06:10:50 +010013rootPath = os.path.join( catchPath, 'include/' )
14versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
15
16
17hashes = runAndCapture( ['git', 'log', '-2', '--format="%H"', versionPath] )
18lines = runAndCapture( ['git', 'log', hashes[1] + ".." + hashes[0], catchPath] )
19
20prevLine = ""
21messages = []
22dates = []
Phil Nash57374a12014-04-26 08:34:24 +010023issues = {}
24
25def getIssueTitle( issueNumber ):
26 try:
27 s = urllib2.urlopen("https://api.github.com/repos/philsquared/catch/issues/" + issueNumber ).read()
Phil Nashad942882017-02-23 08:10:37 +000028 except:
Phil Nash57374a12014-04-26 08:34:24 +010029 return "#HTTP Error#"
30
31 try:
32 j = json.loads( s )
33 return j["title"]
Phil Nashad942882017-02-23 08:10:37 +000034 except:
Phil Nash57374a12014-04-26 08:34:24 +010035 return "#JSON Error#"
36
Phil Nash18845da2014-04-25 06:10:50 +010037for 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 Nash18845da2014-04-25 06:10:50 +010048 prevLine = line
Phil Nash57374a12014-04-26 08:34:24 +010049 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 Nash18845da2014-04-25 06:10:50 +010060
61print "All changes between {0} and {1}:\n".format( dates[-1], dates[0] )
62
63for line in messages:
64 print line