Skip to content

Commit

Permalink
code: Fix error that may occur when 'master branch' does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Apr 18, 2017
1 parent 7f1d6e4 commit 0dd9362
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/CodeApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import utils.ErrorViews;
import utils.FileUtil;
import utils.HttpUtil;
import utils.MenuType;
import views.html.code.nohead;
import views.html.code.nohead_svn;
import views.html.code.view;
Expand Down Expand Up @@ -103,7 +104,7 @@ public static Result codeBrowserWithBranch(String owner, String projectName, Str
Cache.set(cacheKey, recursiveData);
}
if (recursiveData == null) {
return notFound(ErrorViews.NotFound.render());
return notFound(ErrorViews.NotFound.render(branch, project, "code"));
}

return ok(view.render(project, branches, recursiveData, branch, path));
Expand Down
3 changes: 3 additions & 0 deletions app/models/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ public Date lastUpdateDate() {
if (!branches.isEmpty() && repository instanceof GitRepository) {
GitRepository gitRepo = new GitRepository(owner, name);
List<Commit> history = gitRepo.getHistory(0, 2, "HEAD", null);
if(history == null) {
return this.createdDate;
}
return history.get(0).getAuthorDate();
}
} catch (IOException e) {
Expand Down
4 changes: 3 additions & 1 deletion app/views/error/notfound.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
case "issue_post" => utils.MenuType.ISSUE
case "board_post" => utils.MenuType.BOARD
case "milestone" => utils.MenuType.MILESTONE
case "code" => utils.MenuType.CODE
case _ => utils.MenuType.PROJECT_HOME
}
}
Expand All @@ -34,13 +35,14 @@
case "issue_post" => routes.IssueApp.issues(project.owner, project.name, "all")
case "board_post" => routes.BoardApp.posts(project.owner, project.name)
case "milestone" => routes.MilestoneApp.milestones(project.owner, project.name)
case "code" => routes.ProjectApp.settingForm(project.owner, project.name)
case _ => "javascript:history.back();"
}
}

@getMessage(target:String) = @{
if(target){
Messages("error.notfound." + target)
Messages("error.notfound." + target, title)
} else {
Messages("error.notfound")
}
Expand Down
2 changes: 2 additions & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ error.timeout = Your request could not be processed because of server timeout
error.internalServerError = Server error has occurred; service is not available
error.notfound = Page not found
error.notfound.board_post = Post not exists
error.notfound.branch = Branch doesn't exists
error.notfound.code_comment = Commit-comment not exists
error.notfound.code = {0} branch doesn't exists. Check project default branch!
error.notfound.commit = Commit not exists
error.notfound.issue_post = Issue not exists
error.notfound.milestone = Milestone not exists
Expand Down
2 changes: 2 additions & 0 deletions conf/messages.ko-KR
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ error.timeout = 요청 처리가 너무 오래 걸려 중단되었습니다
error.internalServerError = 서버 오류가 발생하여 서비스를 이용할 수 없습니다
error.notfound = 페이지를 찾을 수 없습니다
error.notfound.board_post = 존재하지 않는 글입니다
error.notfound.branch = 브랜치가 존재하지 않습니다
error.notfound.code_comment = 존재하지 않는 커밋 댓글입니다.
error.notfound.code = {0} 브랜치가 없습니다. 기본 브랜치 설정을 확인해 주세요.
error.notfound.commit = 존재하지 않는 커밋입니다.
error.notfound.issue_post = 존재하지 않는 이슈입니다
error.notfound.milestone = 존재하지 않는 마일스톤입니다.
Expand Down

0 comments on commit 0dd9362

Please sign in to comment.