[Notice] Announcing the End of Demo Server [Read me]
김덕홍 2013-10-22
Merge pull request #137 from laziel/yobi refs/heads/yobi-401
@50ece880f795427ab4a7964e9806283bd8741b8d
app/controllers/ProjectApp.java
--- app/controllers/ProjectApp.java
+++ app/controllers/ProjectApp.java
@@ -339,13 +339,13 @@
         if (AccessControl.isAllowed(UserApp.currentUser(), project.asResource(), Operation.DELETE)) {
             RepositoryService.deleteRepository(loginId, projectName, project.vcs);
             project.delete();
-            
+
             // XHR 호출에 의한 경우라면 204 No Content 와 Location 헤더로 응답한다
             if(HttpUtil.isRequestedWithXHR(request())){
                 response().setHeader("Location", routes.Application.index().toString());
-                return status(204);            
+                return status(204);
             }
-            
+
             return redirect(routes.Application.index());
         } else {
             flash(Constants.WARNING, "project.member.isManager");
@@ -511,7 +511,12 @@
         if(!commitId.isEmpty()) {
             addCommitAuthor(RepositoryService.getRepository(pullRequest.fromProject).getCommit(commitId), userList);
         }
-        userList.add(pullRequest.contributor);
+
+        User contributor = pullRequest.contributor;
+        if(!userList.contains(contributor)) {
+            userList.add(contributor);
+        }
+
         userList.remove(UserApp.currentUser());
 
         List<Map<String, String>> mentionList = new ArrayList<>();
app/models/Issue.java
--- app/models/Issue.java
+++ app/models/Issue.java
@@ -344,9 +344,11 @@
     public boolean assignedUserEquals(Assignee otherAssignee) {
         if (assignee == null || assignee.user == null || assignee.user.isAnonymous()) {
             return otherAssignee == null || otherAssignee.user == null || otherAssignee.user.isAnonymous();
-        } else {
-            return assignee.equals(otherAssignee) || assignee.user.equals(otherAssignee.user);
         }
+        if (otherAssignee == null || otherAssignee.user == null || otherAssignee.user.isAnonymous()) {
+            return assignee == null || assignee.user == null || assignee.user.isAnonymous();
+        }
+        return assignee.equals(otherAssignee) || assignee.user.equals(otherAssignee.user);
     }
 
     /**
app/models/PullRequestComment.java
--- app/models/PullRequestComment.java
+++ app/models/PullRequestComment.java
@@ -152,16 +152,18 @@
             path = path.substring(1);
         }
 
+        Repository mergedRepository = pullRequest.getMergedRepository();
+
         if (commitId.equals(commitA)) {
             _isOutdated = !noChangesBetween(GitRepository.buildGitRepository(pullRequest.toProject),
-                    pullRequest.toBranch, commitId, path, line);
+                    pullRequest.toBranch, mergedRepository, commitId, path, line);
         } else {
             if (!commitId.equals(commitB)) {
                 play.Logger.warn(
                         "Invalid PullRequestComment.commitId: It must equal to commitA or commitB.");
             }
             _isOutdated = !noChangesBetween(GitRepository.buildGitRepository(pullRequest.fromProject),
-                        pullRequest.fromBranch, commitId, path, line);
+                        pullRequest.fromBranch, mergedRepository, commitId, path, line);
         }
 
         return _isOutdated;
@@ -210,10 +212,11 @@
      * @return
      * @throws IOException
      */
-    static private boolean noChangesBetween(Repository gitRepo, String rev1, String rev2,
+    static private boolean noChangesBetween(Repository repoA, String rev1,
+                                            Repository repoB, String rev2,
                                             String path, Integer line) throws IOException {
-        String a = getLastChangedCommitUntil(gitRepo, rev1, path, line);
-        String b = getLastChangedCommitUntil(gitRepo, rev2, path, line);
+        String a = getLastChangedCommitUntil(repoA, rev1, path, line);
+        String b = getLastChangedCommitUntil(repoB, rev2, path, line);
 
         return a.equals(b);
     }
app/utils/TemplateHelper.scala
--- app/utils/TemplateHelper.scala
+++ app/utils/TemplateHelper.scala
@@ -16,6 +16,8 @@
 import views.html.partial_diff_line
 import models.PullRequestComment
 import models.TimelineItem
+import models.Project
+import java.net.URLEncoder
 
 object TemplateHelper {
 
@@ -100,6 +102,56 @@
     }
   }
 
+  def branchItemType(branch: String) = {
+    var names = branch.split('/');
+    
+    if(names(0).equals("refs") && names.length >= 3){
+        names(1) match {
+            case "heads" => "branch"
+            case "tags"  => "tag"
+            case _       => names(1)
+        }
+    } else {
+        branch
+    }
+  }
+  
+  def branchItemName(branch: String) = {
+    var names = branch.split('/');
+    
+    if(names(0).equals("refs") && names.length >= 3){
+        names.slice(2, names.length).mkString("/");
+    } else {
+        branch
+    }
+  }
+
+  def branchInHTML(branch: String) = {
+    var names = branch.split('/');
+    var branchType = branchItemType(branch);
+    var branchName = branchItemName(branch);
+    
+    if(names(0).equals("refs") && names.length >= 3){
+        "<span class=\"label " + branchType + "\">" + branchType + "</span>" + branchName
+    } else {
+        branch
+    }
+  }
+  
+  def getBranchURL(project:Project, branchName:String, viewType:String, path:String) = {
+    viewType match {
+        case "history" => {
+            routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(branchName, "UTF-8"), null)
+        }
+        case "code" => {
+            routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, URLEncoder.encode(branchName, "UTF-8"), path)
+        }
+        case _ => {
+            "#"
+        }
+    }
+  }
+    
   object DiffRenderer {
 
     def removedWord(word: String) = "<span class='remove'>" + word + "</span>"
app/views/code/diff.scala.html
--- app/views/code/diff.scala.html
+++ app/views/code/diff.scala.html
@@ -6,31 +6,9 @@
 @import utils.JodaDateUtil._
 @import utils.AccessControl._
 
-@branchItemType(itemType:String) = @{
-    if(itemType == "heads"){
-        "branch"
-    } else {
-        itemType
-    }
-}
-
-@makeBranchItem(project:Project, branch:String) = {
-    @defining(branch.split('/')){ names =>
-        @if(names(0).equals("refs") && names.length == 3){
-            <li data-value="@branch"><a href="@routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(names(2), "UTF-8"), null)"><!--
-             --><span class="label @branchItemType(names(1))">@branchItemType(names(1))</span><!--
-             -->@names(2)
-            </a></li>
-        } else {
-            <li data-value="@branch"><a href="@routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(branch, "UTF-8"), null)">@branch</a></li>
-        }
-    }
-}
-
 @projectLayout(Messages("code.commits") + " @" + commit.getId, project, utils.MenuType.CODE) {
 
 <div class="page">
-
     @projectMenu(project, utils.MenuType.CODE, "main-menu-only")
 
     <div class="code-browse-wrap">
@@ -42,7 +20,7 @@
             <ul class="dropdown-menu">
             @defining(RepositoryService.getRepository(project).getBranches()) { branches =>
                 @for(branch <- branches){
-                    @makeBranchItem(project, branch)
+                    @partial_branchitem(project, branch, "history", "")
                 }
             }
             </ul>
@@ -173,12 +151,12 @@
 <script type="text/javascript">
     $(document).ready(function(){
         $yobi.loadModule("code.Diff", {
-            "welDiff": $("#commit"),
-            "bCommentable"   : @if(isProjectResourceCreatable(UserApp.currentUser, project, ResourceType.COMMIT_COMMENT)){true}else{false},
-            "sWatchUrl"     : "@routes.WatchApp.watch(commit.asResource(project).asParameter)",
-            "sUnwatchUrl"   : "@routes.WatchApp.unwatch(commit.asResource(project).asParameter)",
-            "sTplFileURL"    : "@routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, "${commitId}", "${path}")",
-            "sTplRawURL"     : "@routes.CodeApp.showRawFile(project.owner, project.name, "${commitId}", "${path}")"
+            "welDiff"     : $("#commit"),
+            "bCommentable": @if(isProjectResourceCreatable(UserApp.currentUser, project, ResourceType.COMMIT_COMMENT)){true}else{false},
+            "sWatchUrl"   : "@routes.WatchApp.watch(commit.asResource(project).asParameter)",
+            "sUnwatchUrl" : "@routes.WatchApp.unwatch(commit.asResource(project).asParameter)",
+            "sTplFileURL" : "@routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, "${commitId}", "${path}")",
+            "sTplRawURL"  : "@routes.CodeApp.showRawFile(project.owner, project.name, "${commitId}", "${path}")"
         });
 
         yobi.Mention({
app/views/code/partial_branchitem.scala.html
--- app/views/code/partial_branchitem.scala.html
+++ app/views/code/partial_branchitem.scala.html
@@ -1,40 +1,7 @@
 @(project:Project, branch:String, viewType:String, path:String)
 
-@import java.net.URLEncoder
+@import utils.TemplateHelper._
 
-@branchItemType(itemType:String) = @{
-    if(itemType == "heads"){
-        "branch"
-    } else if(itemType == "tags") {
-        "tag"
-    } else {
-        itemType
-    }
-}
-
-@getBranchURL(project:Project, branchName:String, viewType:String) = @{
-    viewType match {
-        case "history" => {
-            routes.CodeHistoryApp.history(project.owner, project.name, URLEncoder.encode(branchName, "UTF-8"), null)
-        }
-        case "code" => {
-            routes.CodeApp.codeBrowserWithBranch(project.owner, project.name, URLEncoder.encode(branchName, "UTF-8"), path)
-        }
-        case _ => {
-            "#"
-        }
-    }
-}
-
-@defining(branch.split('/')){ names =>
-    @defining(names.slice(2, names.length).mkString("/")){ branchName =>
-        @if(names(0).equals("refs") && names.length >= 3){
-            <li data-value="@branch"><a href="@getBranchURL(project, branchName, viewType)"><!--
-             --><span class="label @branchItemType(names(1))">@branchItemType(names(1))</span><!--
-             -->@branchName
-            </a></li>
-        } else {
-            <li data-value="@branch"><a href="@getBranchURL(project, branch, viewType)">@branch</a></li>
-        }
-    }
+@defining(branchItemName(branch)){ branchName =>
+    <li data-value="@branch"><a href="@getBranchURL(project, branchName, viewType, path)">@Html(branchInHTML(branch))</a></li>
 }
(No newline at end of file)
app/views/git/partial_comments.scala.html
--- app/views/git/partial_comments.scala.html
+++ app/views/git/partial_comments.scala.html
@@ -131,7 +131,7 @@
             <div class="media-body">
                 <div class="meta-info">
                     <span class="comment_author pull-left">
-                        <i class="yobicon-comment"></i>
+                        <i class="yobicon-push"></i>
                         <a href="@routes.UserApp.userInfo(comment.authorLoginId)" data-toggle="tooltip" data-placement="top" title="@comment.authorName">
                             <strong>@comment.authorLoginId </strong>
                         </a>
app/views/help/toc.scala.html
--- app/views/help/toc.scala.html
+++ app/views/help/toc.scala.html
@@ -12,7 +12,7 @@
             <div class="answer-wrap">
                 <i class="yobicon-a a"></i>
                 <div class="answer" style="width:100%">
-                    @Messages("app.name")를 설치하고자 하면 <a href="http://repo.yobi.io/dlab/yobi#korean">http://repo.yobi.io/dlab/yobi#korean</a>를 참고해 주세요.
+                    @Messages("app.name")를 설치하고자 하면 <a href="http://github/nforge/yobi#korean">http://github/nforge/yobi#korean</a>를 참고해 주세요.
                 </div>
             </div>
         </li>
Add a comment
List