diff options
author | James Moger <james.moger@gitblit.com> | 2014-03-31 11:45:21 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-03-31 11:45:21 -0400 |
commit | beb021472d034617e1ce216aee38d918ae7f1a67 (patch) | |
tree | 24aa85d00fdad02934659e0a570bc3540b3a4108 /src/main/java/com/gitblit/git | |
parent | 9cce439817e17616619c189ab0840af29edd36f4 (diff) | |
download | gitblit-beb021472d034617e1ce216aee38d918ae7f1a67.tar.gz gitblit-beb021472d034617e1ce216aee38d918ae7f1a67.zip |
Configure Tickets close-on-push commit message regex (issue-404)
Diffstat (limited to 'src/main/java/com/gitblit/git')
-rw-r--r-- | src/main/java/com/gitblit/git/PatchsetReceivePack.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/com/gitblit/git/PatchsetReceivePack.java b/src/main/java/com/gitblit/git/PatchsetReceivePack.java index 1d3312aa..64a739e5 100644 --- a/src/main/java/com/gitblit/git/PatchsetReceivePack.java +++ b/src/main/java/com/gitblit/git/PatchsetReceivePack.java @@ -897,11 +897,20 @@ public class PatchsetReceivePack extends GitblitReceivePack { if (parseMessage) {
// parse commit message looking for fixes/closes #n
- Pattern p = Pattern.compile("(?:fixes|closes)[\\s-]+#?(\\d+)", Pattern.CASE_INSENSITIVE);
- Matcher m = p.matcher(commit.getFullMessage());
- while (m.find()) {
- String val = m.group(1);
- return Long.parseLong(val);
+ String dx = "(?:fixes|closes)[\\s-]+#?(\\d+)";
+ String x = settings.getString(Keys.tickets.closeOnPushCommitMessageRegex, dx);
+ if (StringUtils.isEmpty(x)) {
+ x = dx;
+ }
+ try {
+ Pattern p = Pattern.compile(x, Pattern.CASE_INSENSITIVE);
+ Matcher m = p.matcher(commit.getFullMessage());
+ while (m.find()) {
+ String val = m.group(1);
+ return Long.parseLong(val);
+ }
+ } catch (Exception e) {
+ LOGGER.error(String.format("Failed to parse \"%s\" in commit %s", x, commit.getName()), e);
}
}
return 0L;
|