From 1e907498a944c22db79e9cfbd26ee7f10fe1a091 Mon Sep 17 00:00:00 2001
From: Sato Hiroyuki <sathiroyuki@gmail.com>
Date: Tue, 5 Feb 2013 12:34:35 +0900
Subject: [PATCH] The commit is marked and displayed in the center.

---
 app/views/graph/show.html.haml            |  3 ++-
 vendor/assets/javascripts/branch-graph.js | 21 +++++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/app/views/graph/show.html.haml b/app/views/graph/show.html.haml
index ca3a8706313..4ca75d68f8c 100644
--- a/app/views/graph/show.html.haml
+++ b/app/views/graph/show.html.haml
@@ -14,6 +14,7 @@
     branch_graph = new BranchGraph($("#holder"), {
       url: '#{project_graph_path(@project, @ref, format: :json)}',
       commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}',
-      ref: '#{@ref}'
+      ref: '#{@ref}',
+      commit_id: '#{@commit && @commit.id}'
     });
   });
diff --git a/vendor/assets/javascripts/branch-graph.js b/vendor/assets/javascripts/branch-graph.js
index 7929d3b2a14..fb22953acd2 100644
--- a/vendor/assets/javascripts/branch-graph.js
+++ b/vendor/assets/javascripts/branch-graph.js
@@ -161,14 +161,23 @@
       
       if (this.commits[i].refs) {
         this.appendLabel(x, y, this.commits[i].refs);
-
-        // The main branch is displayed in the center.
-        re = new RegExp('(^| )' + this.options.ref + '( |$)');
-        if (this.commits[i].refs.match(re)) {
-          scrollLeft = x - graphWidth / 2;
-        }
       }
       
+      // mark commit and displayed in the center
+      if (this.commits[i].id == this.options.commit_id) {
+        r.path([
+            'M', x, y - 5,
+            'L', x + 4, y - 15,
+            'L', x - 4, y - 15,
+            'Z'
+            ]).attr({
+              "fill": "#000",
+              "fill-opacity": .7,
+              "stroke": "none"
+              });
+        scrollLeft = x - graphWidth / 2;
+      }
+
       this.appendAnchor(top, this.commits[i], x, y);
     }
     top.toFront();
-- 
GitLab