use of org.eclipse.jgit.lib.BlobBasedConfig in project gerrit by GerritCodeReview.
the class PushPermissionsIT method administrateServerForUpdateParentDenied.
@Test
public void administrateServerForUpdateParentDenied() throws Exception {
projectOperations.project(project).forUpdate().add(allow(Permission.PUSH).ref("refs/meta/config").group(REGISTERED_USERS)).add(allow(Permission.OWNER).ref("refs/*").group(REGISTERED_USERS)).update();
String project2 = name("project2");
projectOperations.newProject().name(project2).create();
ObjectId oldId = forceFetch("refs/meta/config");
Config cfg = new BlobBasedConfig(null, testRepo.getRepository(), oldId, "project.config");
cfg.setString("access", null, "inheritFrom", project2);
ObjectId newId = testRepo.branch("refs/meta/config").commit().add("project.config", cfg.toText()).create();
PushResult r = push(newId.name() + ":refs/meta/config");
assertThat(r).onlyRef("refs/meta/config").isRejected("invalid project configuration: only Gerrit admin can set parent");
assertThat(r).hasNoMessages();
assertThat(r).hasProcessed(ImmutableMap.of("refs", 1));
}
use of org.eclipse.jgit.lib.BlobBasedConfig in project gitblit by gitblit.
the class JGitUtils method getSubmodules.
/**
* Returns the list of submodules for this repository.
*
* @param repository
* @param commit
* @return list of submodules
*/
public static List<SubmoduleModel> getSubmodules(Repository repository, RevTree tree) {
List<SubmoduleModel> list = new ArrayList<SubmoduleModel>();
byte[] blob = getByteContent(repository, tree, ".gitmodules", false);
if (blob == null) {
return list;
}
try {
BlobBasedConfig config = new BlobBasedConfig(repository.getConfig(), blob);
for (String module : config.getSubsections("submodule")) {
String path = config.getString("submodule", module, "path");
String url = config.getString("submodule", module, "url");
list.add(new SubmoduleModel(module, path, url));
}
} catch (ConfigInvalidException e) {
LOGGER.error("Failed to load .gitmodules file for " + repository.getDirectory(), e);
}
return list;
}
Aggregations