public static String hostName;
@IsAllowed(Operation.READ)
public static Result codeBrowser(String userName, String projectName)
throws IOException, UnsupportedOperationException, ServletException {
Project project = Project.findByOwnerAndProjectName(userName, projectName);
if (!RepositoryService.VCS_GIT.equals(project.vcs) && !RepositoryService.VCS_SUBVERSION.equals(project.vcs)) {
return status(Http.Status.NOT_IMPLEMENTED, project.vcs + " is not supported!");
}
PlayRepository repository = RepositoryService.getRepository(project);
if(repository.isEmpty()) {
switch (project.vcs) {
case RepositoryService.VCS_GIT:
return ok(nohead.render(project));
case RepositoryService.VCS_SUBVERSION:
return ok(nohead_svn.render(project));
}
}
String defaultBranch = project.defaultBranch();
if (defaultBranch == null) {
defaultBranch = "HEAD";
} else if (defaultBranch.split("/").length >= 3) {
defaultBranch = defaultBranch.split("/", 3)[2];
}