final String name = allProjectsName.get();
throw new IOException("Cannot create repository " + name, err);
}
}
try {
MetaDataUpdate md =
new MetaDataUpdate(GitReferenceUpdated.DISABLED, allProjectsName, git);
md.getCommitBuilder().setAuthor(serverUser);
md.getCommitBuilder().setCommitter(serverUser);
ProjectConfig config = ProjectConfig.read(md);
Project p = config.getProject();
p.setDescription("Rights inherited by all other projects");
p.setUseContributorAgreements(false);
AccessSection cap = config.getAccessSection(AccessSection.GLOBAL_CAPABILITIES, true);
AccessSection all = config.getAccessSection(AccessSection.ALL, true);
AccessSection heads = config.getAccessSection(AccessSection.HEADS, true);
AccessSection meta = config.getAccessSection(GitRepositoryManager.REF_CONFIG, true);
cap.getPermission(GlobalCapability.ADMINISTRATE_SERVER, true)
.add(rule(config, admin));
PermissionRule review = rule(config, registered);
review.setRange(-1, 1);
heads.getPermission(Permission.LABEL + "Code-Review", true).add(review);
all.getPermission(Permission.READ, true) //
.add(rule(config, admin));
all.getPermission(Permission.READ, true) //
.add(rule(config, anonymous));
config.getAccessSection("refs/for/" + AccessSection.ALL, true) //
.getPermission(Permission.PUSH, true) //
.add(rule(config, registered));
all.getPermission(Permission.FORGE_AUTHOR, true) //
.add(rule(config, registered));
Permission metaReadPermission = meta.getPermission(Permission.READ, true);
metaReadPermission.setExclusiveGroup(true);
metaReadPermission.add(rule(config, owners));
md.setMessage("Initialized Gerrit Code Review " + Version.getVersion());
config.commit(md);
} finally {
git.close();
}
}