OSDN Git Service

Add link_title to CommitDecorator
authorRobert Speicher <rspeicher@gmail.com>
Sun, 2 Sep 2012 03:56:44 +0000 (23:56 -0400)
committerRobert Speicher <rspeicher@gmail.com>
Sun, 2 Sep 2012 17:40:14 +0000 (13:40 -0400)
app/decorators/commit_decorator.rb
lib/gitlab/markdown.rb

index cc8fa97..074176a 100644 (file)
@@ -1,6 +1,15 @@
 class CommitDecorator < ApplicationDecorator
   decorates :commit
 
+  # Returns a string describing the commit for use in a link title
+  #
+  # Example
+  #
+  #   "Commit: Alex Denisov - Project git clone panel"
+  def link_title
+    "Commit: #{author_name} - #{title}"
+  end
+
   # Returns the commits title.
   #
   # Usually, the commit title is the first line of the commit message.
index 75fa835..9a07133 100644 (file)
@@ -100,7 +100,7 @@ module Gitlab
 
     def reference_commit(identifier)
       if commit = @project.commit(identifier)
-        link_to(identifier, project_commit_path(@project, id: commit.id), html_options.merge(title: "Commit: #{commit.author_name} - #{CommitDecorator.new(commit).title}", class: "gfm gfm-commit #{html_options[:class]}"))
+        link_to(identifier, project_commit_path(@project, id: commit.id), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}"))
       end
     end
   end