Fix PluginConfig.setGroupReference method

When the group reference was a new one, i.e. not already in the groups
file, it was not added to the groups file when saving the project
config.

Change-Id: If40bcc3fae8c1966bda21adc1b6d46d63b88e4ec
This commit is contained in:
Hugo Arès 2017-06-21 08:33:09 -04:00
parent 05996a306d
commit b7b952fe62
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

@ -403,7 +403,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

@ -466,6 +466,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 {