Merge "Fix PluginConfig.setGroupReference method"

This commit is contained in:
Hugo Arès
2017-06-27 18:00:17 +00:00
committed by Gerrit Code Review
3 changed files with 17 additions and 2 deletions

View File

@@ -159,6 +159,7 @@ public class PluginConfig {
}
public void setGroupReference(String name, GroupReference value) {
setString(name, value.toConfigValue());
GroupReference groupRef = projectConfig.resolve(value);
setString(name, groupRef.toConfigValue());
}
}

View File

@@ -416,7 +416,13 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
}
public GroupReference resolve(GroupReference group) {
return groupList.resolve(group);
GroupReference groupRef = groupList.resolve(group);
if (groupRef != null
&& groupRef.getUUID() != null
&& !groupsByName.containsKey(groupRef.getName())) {
groupsByName.put(groupRef.getName(), groupRef);
}
return groupRef;
}
/** @return the group reference, if the group is used by at least one rule. */

View File

@@ -474,6 +474,14 @@ public class ProjectConfigTest extends LocalDiskRepositoryTestCase {
+ "\tkey1 = "
+ staff.toConfigValue()
+ "\n");
assertThat(text(rev, "groups"))
.isEqualTo(
"# UUID\tGroup Name\n" //
+ "#\n" //
+ staff.getUUID().get()
+ " \t"
+ staff.getName()
+ "\n");
}
private ProjectConfig read(RevCommit rev) throws IOException, ConfigInvalidException {