use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method removePermission.
protected void removePermission(Project.NameKey project, String ref, String permission) throws IOException, ConfigInvalidException {
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
md.setMessage(String.format("Remove %s on %s", permission, ref));
ProjectConfig config = ProjectConfig.read(md);
AccessSection s = config.getAccessSection(ref, true);
Permission p = s.getPermission(permission, true);
p.getRules().clear();
config.commit(md);
projectCache.evict(config.getProject());
}
}
use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method setUseContributorAgreements.
protected void setUseContributorAgreements(InheritableBoolean value) throws Exception {
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
ProjectConfig config = ProjectConfig.read(md);
config.getProject().setUseContributorAgreements(value);
config.commit(md);
projectCache.evict(config.getProject());
}
}
use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class ChangeIT method checkLabelsForOpenChange.
@Test
public void checkLabelsForOpenChange() throws Exception {
PushOneCommit.Result r = createChange();
ChangeInfo change = gApi.changes().id(r.getChangeId()).get();
assertThat(change.status).isEqualTo(ChangeStatus.NEW);
assertThat(change.labels.keySet()).containsExactly("Code-Review");
assertThat(change.permittedLabels.keySet()).containsExactly("Code-Review");
// add new label and assert that it's returned for existing changes
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
LabelType verified = Util.verified();
cfg.getLabelSections().put(verified.getName(), verified);
AccountGroup.UUID registeredUsers = systemGroupBackend.getGroup(REGISTERED_USERS).getUUID();
String heads = RefNames.REFS_HEADS + "*";
Util.allow(cfg, Permission.forLabel(verified.getName()), -1, 1, registeredUsers, heads);
saveProjectConfig(project, cfg);
change = gApi.changes().id(r.getChangeId()).get();
assertThat(change.labels.keySet()).containsExactly("Code-Review", "Verified");
assertThat(change.permittedLabels.keySet()).containsExactly("Code-Review", "Verified");
assertPermitted(change, "Code-Review", -2, -1, 0, 1, 2);
assertPermitted(change, "Verified", -1, 0, 1);
// add an approval on the new label
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(new ReviewInput().label(verified.getName(), verified.getMax().getValue()));
// remove label and assert that it's no longer returned for existing
// changes, even if there is an approval for it
cfg.getLabelSections().remove(verified.getName());
Util.remove(cfg, Permission.forLabel(verified.getName()), registeredUsers, heads);
saveProjectConfig(project, cfg);
change = gApi.changes().id(r.getChangeId()).get();
assertThat(change.labels.keySet()).containsExactly("Code-Review");
assertThat(change.permittedLabels.keySet()).containsExactly("Code-Review");
}
use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class AbstractPushForReview method setUp.
@Before
public void setUp() throws Exception {
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
patchSetLock = Util.patchSetLock();
cfg.getLabelSections().put(patchSetLock.getName(), patchSetLock);
AccountGroup.UUID anonymousUsers = systemGroupBackend.getGroup(ANONYMOUS_USERS).getUUID();
Util.allow(cfg, Permission.forLabel(patchSetLock.getName()), 0, 1, anonymousUsers, "refs/heads/*");
saveProjectConfig(cfg);
grant(project, "refs/heads/*", Permission.LABEL + "Patch-Set-Lock");
}
use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class AbstractPushForReview method enableCreateNewChangeForAllNotInTarget.
private void enableCreateNewChangeForAllNotInTarget() throws Exception {
ProjectConfig config = projectCache.checkedGet(project).getConfig();
config.getProject().setCreateNewChangeForAllNotInTarget(InheritableBoolean.TRUE);
saveProjectConfig(project, config);
}
Aggregations