in src/main/java/com/googlesource/gerrit/plugins/deleteproject/DeletePreconditions.java [151:171]
private void assertIsNotSubmodule(Project.NameKey projectNameKey)
throws CannotDeleteProjectException {
try (Repository repo = repoManager.openRepository(projectNameKey);
MergeOpRepoManager mergeOp = mergeOpProvider.get()) {
Set<BranchNameKey> branches =
repo.getRefDatabase().getRefsByPrefix(REFS_HEADS).stream()
.map(ref -> BranchNameKey.create(projectNameKey, ref.getName()))
.collect(toSet());
SubscriptionGraph graph = subscriptionGraphFactory.compute(branches, mergeOp);
for (BranchNameKey b : branches) {
if (graph.hasSuperproject(b)) {
throw new CannotDeleteProjectException("Project is subscribed by other projects.");
}
}
} catch (RepositoryNotFoundException e) {
// we're trying to delete the repository,
// so this exception should not stop us
} catch (IOException | SubmoduleConflictException e) {
throw new CannotDeleteProjectException("Project is subscribed by other projects.", e);
}
}