Permalink
Browse files

Optionally search commit message for Gerrit tracking IDs

By default the subject is searched for the issue ID, however by adding
the following configuration option to ~/.jirretconfig Jirret will search
the whole message for tracking IDs:

    use_trackingid=true
  • Loading branch information...
Andrew Jeffery
Andrew Jeffery committed Mar 8, 2012
1 parent b9a78b3 commit 9110ba787c417b4c83157424093276e7b52e57af
Showing with 14 additions and 4 deletions.
  1. +10 −4 hooks/jirret-process-hook
  2. +4 −0 jirretconfig.example
View
@@ -25,12 +25,13 @@ url = config.get('jira', 'url')
gerrit_cmd = config.get('jira', 'gerritcmd')
custom_field = config.get('jira', 'custom_field')
+use_trackingid_option = ('jira', 'use_trackingid')
+use_trackingid = config.get(*use_trackingid_option).lower() == 'true' \
+ if config.has_option(*use_trackingid_option) else False
+
rpc = xmlrpclib.ServerProxy(url)
auth = rpc.jira1.login(user, password)
-
-
-
def showUsage():
print '\nNormal hook usage: ' + sys.argv[0] + ' --action [new|merged|abandoned] --change <change id> --commit <git hash> --change-url <url to change>'
print '\nTo automatically update projects list in config: ' + sys.argv[0] + ' update-projects'
@@ -60,9 +61,14 @@ def updateTicket(what, id, hash, url, who, branch):
issues = []
print projects
+ issue_needle = '(%s-[0-9]+)'
+ issue_haystack = subject
+ if use_trackingid:
+ issue_needle = ' +id: +' + issue_needle
+ issue_haystack = out
for p in projects:
print issues
- matches = re.findall('(' + p + '-[0-9]+)+', subject)
+ matches = re.findall(issue_needle % p, issue_haystack)
print matches
for m in matches:
issues.append(m)
View
@@ -22,3 +22,7 @@ custom_field=
# if ommited, you must run "./hooks/jirret-process-hook update-projects" after setting up the above
# credentials to automatically fill in the projects list
projects=
+
+# Set to 'true' if you'd like Jirret to search for Gerrit tracking IDs rather
+# than in the subject line for your issue IDs
+use_trackingid=false

0 comments on commit 9110ba7

Please sign in to comment.