Merge pull request #237 from CedricGatay/feature/expand_issues_ref_in_commit
Autolinks to issues in commit message (see #155)
This commit is contained in:
commit
5d6e79f4b9
3 changed files with 88 additions and 2 deletions
|
@ -23,4 +23,24 @@ module CommitsHelper
|
|||
link_to "More", project_commits_path(@project, :offset => offset.to_i + limit.to_i, :limit => limit),
|
||||
:remote => true, :class => "lite_button vm", :style => "text-align:center; width:930px; ", :id => "more-commits-link"
|
||||
end
|
||||
|
||||
def commit_msg_with_link_to_issues(project, message)
|
||||
return '' unless message
|
||||
out = ''
|
||||
message.split(/(#[0-9]+)/m).each do |m|
|
||||
if m =~ /(#([0-9]+))/m
|
||||
begin
|
||||
issue = Issue.find($2)
|
||||
raise Exception('Issue not belonging to current project, not creating link !') unless issue.project_id == project.id
|
||||
out += link_to($1, project_issue_path(project, $2))
|
||||
rescue
|
||||
out += $1
|
||||
end
|
||||
else
|
||||
out += m
|
||||
end
|
||||
end
|
||||
preserve out
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
%hr
|
||||
%pre.commit_message
|
||||
= preserve @commit.safe_message
|
||||
|
||||
= commit_msg_with_link_to_issues(@project, @commit.safe_message)
|
||||
.clear
|
||||
%br
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue