Commit 40d619107f9027a33eccc01afa120f7b588e5cf9

Authored by Robert Speicher
1 parent 8db2a59d

Add link_title to CommitDecorator

app/decorators/commit_decorator.rb
1 class CommitDecorator < ApplicationDecorator 1 class CommitDecorator < ApplicationDecorator
2 decorates :commit 2 decorates :commit
3 3
  4 + # Returns a string describing the commit for use in a link title
  5 + #
  6 + # Example
  7 + #
  8 + # "Commit: Alex Denisov - Project git clone panel"
  9 + def link_title
  10 + "Commit: #{author_name} - #{title}"
  11 + end
  12 +
4 # Returns the commits title. 13 # Returns the commits title.
5 # 14 #
6 # Usually, the commit title is the first line of the commit message. 15 # Usually, the commit title is the first line of the commit message.
lib/gitlab/markdown.rb
@@ -100,7 +100,7 @@ module Gitlab @@ -100,7 +100,7 @@ module Gitlab
100 100
101 def reference_commit(identifier) 101 def reference_commit(identifier)
102 if commit = @project.commit(identifier) 102 if commit = @project.commit(identifier)
103 - 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]}")) 103 + 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]}"))
104 end 104 end
105 end 105 end
106 end 106 end