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:
Valeriy Sizov 2011-12-27 14:49:38 -08:00
commit 5d6e79f4b9
3 changed files with 88 additions and 2 deletions

View file

@ -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

View file

@ -18,8 +18,7 @@
%hr
%pre.commit_message
= preserve @commit.safe_message
= commit_msg_with_link_to_issues(@project, @commit.safe_message)
.clear
%br