Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 66 lines (52 sloc) 1.67 KB
#!/usr/bin/env python
from commands import getoutput
from datetime import date
from os import path, environ
import sys
import re
import fileinput
#TODO: Make the Date/Name/Email line optional
#cl_name = environ.get('CHANGE_LOG_NAME')
#cl_email = environ.get('CHANGE_LOG_EMAIL_ADDRESS')
diff_cmd = ""
is_git = False
is_svn = False
def print_message_line(l):
global is_git
if is_git:
print "#%s" % l
print l
if path.isdir('./.svn'):
diff_cmd = "svn diff"
is_svn = True
elif path.isdir('./.git'):
# Require pwd to be root of git repo, since diff is *not* relative, to avoid confusion.
# Since this is done just before a commit, only capture staged changes.
# Use --no-prefix to look more like an svn diff.
diff_cmd = "git diff --cached --no-prefix"
is_git = True
print "ERROR: Called from outside a Subversion checkout or root of git repository"
first_line = True;
if is_svn:
print "--This line, and those below, will be ignored--"
#print_message_line("%s %s <%s>" % ('%Y-%m-%d'), cl_name, cl_email))
df = getoutput("%s | filterdiff -i'*ChangeLog' | grep ^+" % diff_cmd)
for line in df.split('\n'):
line = line.strip('+')
if line == "":
# Example: +++ UIAutomationWinforms/ChangeLog (working copy)
m = re.match('^ (.*)/ChangeLog', line)
if not m == None:
if first_line: first_line = False
else: print_message_line("")
print_message_line('In %s/:' %
m = re.match('^\d{4}-\d{2}-\d{2}', line)
if not m == None:
Something went wrong with that request. Please try again.