use of com.google.gerrit.server.git.MetaDataUpdate in project gerrit by GerritCodeReview.
the class SetDiffPreferences method writeToGit.
private DiffPreferencesInfo writeToGit(DiffPreferencesInfo in) throws RepositoryNotFoundException, IOException, ConfigInvalidException {
DiffPreferencesInfo out = new DiffPreferencesInfo();
try (MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName)) {
VersionedAccountPreferences prefs = VersionedAccountPreferences.forDefault();
prefs.load(md);
DiffPreferencesInfo defaults = DiffPreferencesInfo.defaults();
storeSection(prefs.getConfig(), UserConfigSections.DIFF, null, in, defaults);
prefs.commit(md);
loadSection(prefs.getConfig(), UserConfigSections.DIFF, null, out, DiffPreferencesInfo.defaults(), null);
}
return out;
}
use of com.google.gerrit.server.git.MetaDataUpdate in project gerrit by GerritCodeReview.
the class CreateProject method createProjectConfig.
private void createProjectConfig(CreateProjectArgs args) throws IOException, ConfigInvalidException {
try (MetaDataUpdate md = metaDataUpdateFactory.create(args.getProject())) {
ProjectConfig config = ProjectConfig.read(md);
Project newProject = config.getProject();
newProject.setDescription(args.projectDescription);
newProject.setSubmitType(MoreObjects.firstNonNull(args.submitType, repositoryCfg.getDefaultSubmitType(args.getProject())));
newProject.setUseContributorAgreements(args.contributorAgreements);
newProject.setUseSignedOffBy(args.signedOffBy);
newProject.setUseContentMerge(args.contentMerge);
newProject.setCreateNewChangeForAllNotInTarget(args.newChangeForAllNotInTarget);
newProject.setRequireChangeID(args.changeIdRequired);
newProject.setMaxObjectSizeLimit(args.maxObjectSizeLimit);
if (args.newParent != null) {
newProject.setParentName(args.newParent.getProject().getNameKey());
}
if (!args.ownerIds.isEmpty()) {
AccessSection all = config.getAccessSection(AccessSection.ALL, true);
for (AccountGroup.UUID ownerId : args.ownerIds) {
GroupDescription.Basic g = groupBackend.get(ownerId);
if (g != null) {
GroupReference group = config.resolve(GroupReference.forGroup(g));
all.getPermission(Permission.OWNER, true).add(new PermissionRule(group));
}
}
}
md.setMessage("Created project\n");
config.commit(md);
md.getRepository().setGitwebDescription(args.projectDescription);
}
projectCache.onCreateProject(args.getProject());
}
Aggregations