doortts doortts 2017-04-18
code: Fix error that may occur when 'master branch' does not exist
@0dd93624d7ef7233cd67d2d5ce677d7f13b938b5
app/controllers/CodeApp.java
--- app/controllers/CodeApp.java
+++ app/controllers/CodeApp.java
@@ -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;
@@ -103,7 +104,7 @@
             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));
app/models/Project.java
--- app/models/Project.java
+++ app/models/Project.java
@@ -256,6 +256,9 @@
             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) {
app/views/error/notfound.scala.html
--- app/views/error/notfound.scala.html
+++ app/views/error/notfound.scala.html
@@ -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
     }
 }
@@ -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")
     }
conf/messages
--- conf/messages
+++ conf/messages
@@ -211,7 +211,9 @@
 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
conf/messages.ko-KR
--- conf/messages.ko-KR
+++ conf/messages.ko-KR
@@ -213,7 +213,9 @@
 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 = 존재하지 않는 마일스톤입니다.
Add a comment
List