diff options
author | Valeriy Sizov <vsv2711@gmail.com> | 2011-12-27 14:49:38 -0800 |
---|---|---|
committer | Valeriy Sizov <vsv2711@gmail.com> | 2011-12-27 14:49:38 -0800 |
commit | 5d6e79f4b97290829e4c22aecf91e57519107a5c (patch) | |
tree | 29c52b2fbad0f74f34a9c9c1bf4f2e8b5b83f698 /app | |
parent | 86d18ca715a2ecf0a572013bcd64aa93f6d8765f (diff) | |
parent | 0aef2fe437d5f2e46a2de379610352bb97d65f6c (diff) | |
download | gitlab-ce-5d6e79f4b97290829e4c22aecf91e57519107a5c.tar.gz |
Merge pull request #237 from CedricGatay/feature/expand_issues_ref_in_commit
Autolinks to issues in commit message (see #155)
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/commits_helper.rb | 20 | ||||
-rw-r--r-- | app/views/commits/show.html.haml | 3 |
2 files changed, 21 insertions, 2 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 98ec9936f11..035fd39cc0e 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -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 diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml index 57ada2df40e..44b7b8fa293 100644 --- a/app/views/commits/show.html.haml +++ b/app/views/commits/show.html.haml @@ -18,8 +18,7 @@ %hr %pre.commit_message - = preserve @commit.safe_message - + = commit_msg_with_link_to_issues(@project, @commit.safe_message) .clear %br |