Merge "Allow to specify multiple 'footer' tags per trackingid entry"

This commit is contained in:
Edwin Kempin 2015-02-19 11:17:51 +00:00 committed by Gerrit Code Review
commit 009520a21d
2 changed files with 22 additions and 8 deletions

View File

@ -3363,6 +3363,7 @@ bug:<tracking id>.
----
[trackingid "jira-bug"]
footer = Bugfix:
footer = Bug:
match = JRA\\d{2,8}
system = JIRA
@ -3374,11 +3375,15 @@ bug:<tracking id>.
[[trackingid.name.footer]]trackingid.<name>.footer::
+
A prefix tag that identify the footer line to parse for tracking ids.
Several trackingid entries can have the same footer tag. A single
trackingid entry can have multiple footer tags. If multiple footer
tags are specified, each tag will be parsed separately.
(the trailing ":" is optional)
A prefix tag that identifies the footer line to parse for tracking ids.
+
Several trackingid entries can have the same footer tag, and a single trackingid
entry can have multiple footer tags.
+
If multiple footer tags are specified, each tag will be parsed separately and
duplicates will be ignored.
+
The trailing ":" is optional.
[[trackingid.name.match]]trackingid.<name>.match::
+

View File

@ -24,7 +24,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.PatternSyntaxException;
/** Provides a list of all configured {@link TrackingFooter}s. */
@ -43,8 +47,11 @@ public class TrackingFootersProvider implements Provider<TrackingFooters> {
for (String name : cfg.getSubsections(TRACKING_ID_TAG)) {
boolean configValid = true;
String footer = cfg.getString(TRACKING_ID_TAG, name, FOOTER_TAG);
if (footer == null || footer.isEmpty()) {
Set<String> footers = new HashSet<>(
Arrays.asList(cfg.getStringList(TRACKING_ID_TAG, name, FOOTER_TAG)));
footers.removeAll(Collections.singleton(null));
if (footers.isEmpty()) {
configValid = false;
log.error("Missing " + TRACKING_ID_TAG + "." + name + "." + FOOTER_TAG
+ " in gerrit.config");
@ -71,7 +78,9 @@ public class TrackingFootersProvider implements Provider<TrackingFooters> {
if (configValid) {
try {
for (String footer : footers) {
trackingFooters.add(new TrackingFooter(footer, match, system));
}
} catch (PatternSyntaxException e) {
log.error("Invalid pattern \"" + match + "\" in gerrit.config "
+ TRACKING_ID_TAG + "." + name + "." + REGEX_TAG + ": "