use of com.google.gerrit.server.git.GitRepositoryManager.Status in project gerrit by GerritCodeReview.
the class ProjectCreator method createProject.
public ProjectState createProject(CreateProjectArgs args) throws BadRequestException, ResourceConflictException, IOException, ConfigInvalidException {
final Project.NameKey nameKey = args.getProject();
try {
final String head = args.permissionsOnly ? RefNames.REFS_CONFIG : args.branch.get(0);
Status status = repoManager.getRepositoryStatus(nameKey);
if (!status.equals(Status.NON_EXISTENT)) {
throw new RepositoryExistsException(nameKey, "Repository status: " + status);
}
try (Repository repo = repoManager.createRepository(nameKey)) {
RefUpdate u = repo.updateRef(Constants.HEAD);
u.disableRefLog();
u.link(head);
createProjectConfig(args);
if (!args.permissionsOnly && args.createEmptyCommit) {
createEmptyCommits(repo, nameKey, args.branch);
}
fire(nameKey, head);
return projectCache.get(nameKey).orElseThrow(illegalState(nameKey));
}
} catch (RepositoryExistsException e) {
throw new ResourceConflictException("Cannot create " + nameKey.get() + " because the name is already occupied by another project.", e);
} catch (RepositoryNotFoundException badName) {
throw new BadRequestException("invalid project name: " + nameKey, badName);
}
}
Aggregations