[project.config] Allow to add commentLink entries

Change-Id: I2fd01cb6775a905d7e602d5415102b274bd98fd3
This commit is contained in:
Hector Oswaldo Caballero
2018-01-16 11:06:54 -05:00
parent 0ff89430af
commit 9fcc0fc0b8
2 changed files with 35 additions and 1 deletions

View File

@@ -227,6 +227,10 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
return new CommentLinkInfoImpl(name, match, link, html, enabled);
}
public void addCommentLinkSection(CommentLinkInfoImpl commentLink) {
commentLinkSections.add(commentLink);
}
public ProjectConfig(Project.NameKey projectName) {
this.projectName = projectName;
}
@@ -932,7 +936,6 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
rc.getString(COMMENTLINK, name, KEY_MATCH), name, e.getMessage())));
}
}
commentLinkSections = ImmutableList.copyOf(commentLinkSections);
}
private void loadSubscribeSections(Config rc) throws ConfigInvalidException {
@@ -1055,6 +1058,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
savePluginSections(rc, keepGroups);
groupList.retainUUIDs(keepGroups);
saveLabelSections(rc);
saveCommentLinkSections(rc);
saveSubscribeSections(rc);
saveConfig(PROJECT_CONFIG, rc);
@@ -1100,6 +1104,23 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
}
}
private void saveCommentLinkSections(Config rc) {
if (commentLinkSections != null) {
for (CommentLinkInfoImpl cm : commentLinkSections) {
rc.setString(COMMENTLINK, cm.name, KEY_MATCH, cm.match);
if (!Strings.isNullOrEmpty(cm.html)) {
rc.setString(COMMENTLINK, cm.name, KEY_HTML, cm.html);
}
if (!Strings.isNullOrEmpty(cm.link)) {
rc.setString(COMMENTLINK, cm.name, KEY_LINK, cm.link);
}
if (cm.enabled != null && !cm.enabled) {
rc.setBoolean(COMMENTLINK, cm.name, KEY_ENABLED, cm.enabled);
}
}
}
}
private void saveContributorAgreements(Config rc, Set<AccountGroup.UUID> keepGroups) {
for (ContributorAgreement ca : sort(contributorAgreements.values())) {
set(rc, CONTRIBUTOR_AGREEMENT, ca.getName(), KEY_DESCRIPTION, ca.getDescription());