releaseNotes.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python3
  2. from __future__ import print_function
  3. import os
  4. import re
  5. import urllib2
  6. import json
  7. from scriptCommon import catchPath
  8. from scriptCommon import runAndCapture
  9. issueNumberRe = re.compile( r'(.*?)#([0-9]*)([^0-9]?.*)' )
  10. rootPath = os.path.join( catchPath, 'include/' )
  11. versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
  12. hashes = runAndCapture( ['git', 'log', '-2', '--format="%H"', versionPath] )
  13. lines = runAndCapture( ['git', 'log', hashes[1] + ".." + hashes[0], catchPath] )
  14. prevLine = ""
  15. messages = []
  16. dates = []
  17. issues = {}
  18. def getIssueTitle( issueNumber ):
  19. try:
  20. s = urllib2.urlopen("https://api.github.com/repos/philsquared/catch/issues/" + issueNumber ).read()
  21. except:
  22. return "#HTTP Error#"
  23. try:
  24. j = json.loads( s )
  25. return j["title"]
  26. except:
  27. return "#JSON Error#"
  28. for line in lines:
  29. if line.startswith( "commit"):
  30. pass
  31. elif line.startswith( "Author:"):
  32. pass
  33. elif line.startswith( "Date:"):
  34. dates.append( line[5:].lstrip() )
  35. elif line == "" and prevLine == "":
  36. pass
  37. else:
  38. prevLine = line
  39. match = issueNumberRe.match( line )
  40. line2 = ""
  41. while match:
  42. issueNumber = match.group(2)
  43. issue = '#{0} ("{1}")'.format( issueNumber, getIssueTitle( issueNumber ) )
  44. line2 = line2 + match.group(1) + issue
  45. match = issueNumberRe.match( match.group(3) )
  46. if line2 == "":
  47. messages.append( line )
  48. else:
  49. messages.append( line2 )
  50. print("All changes between {0} and {1}:\n".format( dates[-1], dates[0] ))
  51. for line in messages:
  52. print(line)