use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class Schema_135 method migrateData.
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
try (Repository git = repoManager.openRepository(allProjectsName);
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allProjectsName, git)) {
ProjectConfig config = ProjectConfig.read(md);
AccessSection meta = config.getAccessSection(RefNames.REFS_CONFIG, true);
Permission createRefsMetaConfigPermission = meta.getPermission(Permission.CREATE, true);
Set<GroupReference> groups = Stream.concat(config.getAccessSection(AccessSection.GLOBAL_CAPABILITIES, true).getPermission(GlobalCapability.ADMINISTRATE_SERVER, true).getRules().stream().map(PermissionRule::getGroup), Stream.of(systemGroupBackend.getGroup(PROJECT_OWNERS))).filter(g -> createRefsMetaConfigPermission.getRule(g) == null).collect(toSet());
for (GroupReference group : groups) {
createRefsMetaConfigPermission.add(new PermissionRule(config.resolve(group)));
}
md.getCommitBuilder().setAuthor(serverUser);
md.getCommitBuilder().setCommitter(serverUser);
md.setMessage(COMMIT_MSG);
config.commit(md);
} catch (ConfigInvalidException | IOException ex) {
throw new OrmException(ex);
}
}
use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class Schema_125 method getLabelTypes.
private Collection<LabelType> getLabelTypes(ProjectConfig config) throws IOException, ConfigInvalidException {
Map<String, LabelType> labelTypes = new HashMap<>(config.getLabelSections());
Project.NameKey parent = config.getProject().getParent(allProjectsName);
while (parent != null) {
try (Repository git = repoManager.openRepository(parent);
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, parent, git)) {
ProjectConfig parentConfig = ProjectConfig.read(md);
for (LabelType lt : parentConfig.getLabelSections().values()) {
if (!labelTypes.containsKey(lt.getName())) {
labelTypes.put(lt.getName(), lt);
}
}
parent = parentConfig.getProject().getParent(allProjectsName);
}
}
return labelTypes.values();
}
use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class AbstractPushForReview method testPushWithInvalidChangeIdFromEgit.
private void testPushWithInvalidChangeIdFromEgit() throws Exception {
createCommit(testRepo, "Message with invalid Change-Id\n" + "\n" + "Change-Id: I0000000000000000000000000000000000000000\n");
pushForReviewRejected(testRepo, "invalid Change-Id line format in commit message footer");
ProjectConfig config = projectCache.checkedGet(project).getConfig();
config.getProject().setRequireChangeID(InheritableBoolean.FALSE);
saveProjectConfig(project, config);
pushForReviewRejected(testRepo, "invalid Change-Id line format in commit message footer");
}
use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class ChangeRebuilderIT method allowRunAs.
private void allowRunAs() throws Exception {
ProjectConfig cfg = projectCache.checkedGet(allProjects).getConfig();
Util.allow(cfg, GlobalCapability.RUN_AS, systemGroupBackend.getGroup(REGISTERED_USERS).getUUID());
saveProjectConfig(allProjects, cfg);
}
use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.
the class ProjectWatchIT method noNotificationForDraftPatchSetsForWatchersInNotifyConfig.
@Test
public void noNotificationForDraftPatchSetsForWatchersInNotifyConfig() throws Exception {
Address addr = new Address("Watcher", "watcher@example.com");
NotifyConfig nc = new NotifyConfig();
nc.addEmail(addr);
nc.setName("team");
nc.setHeader(NotifyConfig.Header.TO);
nc.setTypes(EnumSet.of(NotifyType.NEW_PATCHSETS, NotifyType.ALL_COMMENTS));
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
cfg.putNotifyConfig("team", nc);
saveProjectConfig(project, cfg);
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), testRepo, "subject", "a", "a1").to("refs/for/master");
r.assertOkStatus();
sender.clear();
r = pushFactory.create(db, admin.getIdent(), testRepo, "subject", "a", "a2", r.getChangeId()).to("refs/for/master%draft");
r.assertOkStatus();
assertThat(sender.getMessages()).isEmpty();
setApiUser(admin);
ReviewInput in = new ReviewInput();
in.message = "comment";
gApi.changes().id(r.getChangeId()).current().review(in);
assertThat(sender.getMessages()).isEmpty();
}
Aggregations