]> source.dussan.org Git - gitblit.git/commitdiff
Configure Tickets close-on-push commit message regex (issue-404)
authorJames Moger <james.moger@gitblit.com>
Mon, 31 Mar 2014 15:45:21 +0000 (11:45 -0400)
committerJames Moger <james.moger@gitblit.com>
Mon, 31 Mar 2014 15:45:21 +0000 (11:45 -0400)
releases.moxie
src/main/distrib/data/gitblit.properties
src/main/java/com/gitblit/git/PatchsetReceivePack.java

index 11d2a4126515e198b9bb1018e6e6bc4de6ac2b8e..fc679ef102d1666447ae2a371e640651751775bb 100644 (file)
@@ -15,6 +15,7 @@ r22: {
     - Ensure the Lucene ticket index is updated on repository deletion.
     changes:
     - Specify the --dailyLogFile option for the Ubuntu and CentOS service scripts (issue-348)
+    - The ticket close-on-push commit message regular expression is now configurable by a setting (issue-404)
     - Option to allow LDAP users to directly authenticate without performing LDAP searches (pr-162)
     - Replace JCommander with args4j to be consistent with other tools (ticket-28)
     additions:
@@ -29,6 +30,7 @@ r22: {
     - Jeremie Brebec
     settings:
     - { name: 'realm.ldap.bindpattern', defaultValue: ' ' }
+    - { name: 'tickets.closeOnPushCommitMessageRegex', defaultValue: '(?:fixes|closes)[\\s-]+#?(\\d+)' }
 }
 
 #
index b819b381ab0d560b97700f87ccf1b8f7c6426846..3c6053940512cdf6419abb55a4001eb7c3647c74 100644 (file)
@@ -479,6 +479,13 @@ tickets.acceptNewPatchsets = true
 # SINCE 1.4.0\r
 tickets.requireApproval = false\r
 \r
+# The case-insensitive regular expression used to identify and close tickets on\r
+# push to the integration branch for commits that are NOT already referenced as\r
+# a patchset tip.\r
+#\r
+# SINCE 1.5.0\r
+tickets.closeOnPushCommitMessageRegex = (?:fixes|closes)[\\s-]+#?(\\d+)\r
+\r
 # Specify the location of the Lucene Ticket index\r
 #\r
 # SINCE 1.4.0\r
index 1d3312aa6ab2b72b7f7d12e789e5a8923fb134a4..64a739e59fa20890b77cc459d4ec8d73361ec423 100644 (file)
@@ -897,11 +897,20 @@ public class PatchsetReceivePack extends GitblitReceivePack {
 \r
                if (parseMessage) {\r
                        // parse commit message looking for fixes/closes #n\r
-                       Pattern p = Pattern.compile("(?:fixes|closes)[\\s-]+#?(\\d+)", Pattern.CASE_INSENSITIVE);\r
-                       Matcher m = p.matcher(commit.getFullMessage());\r
-                       while (m.find()) {\r
-                               String val = m.group(1);\r
-                               return Long.parseLong(val);\r
+                       String dx = "(?:fixes|closes)[\\s-]+#?(\\d+)";\r
+                       String x = settings.getString(Keys.tickets.closeOnPushCommitMessageRegex, dx);\r
+                       if (StringUtils.isEmpty(x)) {\r
+                               x = dx;\r
+                       }\r
+                       try {\r
+                               Pattern p = Pattern.compile(x, Pattern.CASE_INSENSITIVE);\r
+                               Matcher m = p.matcher(commit.getFullMessage());\r
+                               while (m.find()) {\r
+                                       String val = m.group(1);\r
+                                       return Long.parseLong(val);\r
+                               }\r
+                       } catch (Exception e) {\r
+                               LOGGER.error(String.format("Failed to parse \"%s\" in commit %s", x, commit.getName()), e);\r
                        }\r
                }\r
                return 0L;\r