Commit bf166e7cfb23634d72ac0857ca7b661a38587f19
1 parent
98f4db15
Exists in
master
and in
1 other branch
Allow the user to provide a redmine url for linking to codebase. The same as the
github url, but points to a redmine repo. The format of the link is something like: https://redmine.example.com/projects/my_great_project/repository/revisions/master/entry after that file path and line number are appended. Conflicts: app/views/notices/_backtrace.html.haml
Showing
5 changed files
with
36 additions
and
10 deletions
Show diff stats
app/helpers/errs_helper.rb
... | ... | @@ -15,4 +15,12 @@ module ErrsHelper |
15 | 15 | link_to(text || file_name, "#{app.github_url_to_file(file_path)}#L#{line_number}", :target => '_blank') |
16 | 16 | end |
17 | 17 | |
18 | -end | |
19 | 18 | \ No newline at end of file |
19 | + def link_to_redmine app, line, text=nil | |
20 | + file_name = line['file'].split('/').last | |
21 | + file_path = line['file'].gsub('[PROJECT_ROOT]', '') | |
22 | + line_number = line['number'] | |
23 | + lnk = "%s%s#L%s" % [ app.redmine_url, file_path, line_number] | |
24 | + link_to(text || file_name, lnk, :target => '_blank') | |
25 | + end | |
26 | + | |
27 | +end | ... | ... |
app/helpers/notices_helper.rb
... | ... | @@ -3,4 +3,17 @@ module NoticesHelper |
3 | 3 | def notice_atom_summary notice |
4 | 4 | render :partial => "notices/atom_entry.html.haml", :locals => {:notice => notice} |
5 | 5 | end |
6 | -end | |
7 | 6 | \ No newline at end of file |
7 | + | |
8 | + def render_line_number(app, line) | |
9 | + unless Notice.in_app_backtrace_line?(line) | |
10 | + line['number'] | |
11 | + else | |
12 | + case true | |
13 | + when app.github_url? then link_to_github(app, line, line['number']) | |
14 | + when app.redmine_url? then link_to_redmine(app, line, line['number']) | |
15 | + else | |
16 | + line['number'] | |
17 | + end | |
18 | + end | |
19 | + end | |
20 | +end | ... | ... |
app/models/app.rb
... | ... | @@ -5,6 +5,7 @@ class App |
5 | 5 | field :name, :type => String |
6 | 6 | field :api_key |
7 | 7 | field :github_url |
8 | + field :redmine_url | |
8 | 9 | field :resolve_errs_on_deploy, :type => Boolean, :default => false |
9 | 10 | field :notify_all_users, :type => Boolean, :default => false |
10 | 11 | field :notify_on_errs, :type => Boolean, :default => true |
... | ... | @@ -66,6 +67,10 @@ class App |
66 | 67 | self.github_url.present? |
67 | 68 | end |
68 | 69 | |
70 | + def redmine_url? | |
71 | + self.redmine_url.present? | |
72 | + end | |
73 | + | |
69 | 74 | def github_url_to_file(file) |
70 | 75 | "#{self.github_url}/blob/master#{file}" |
71 | 76 | end | ... | ... |
app/views/apps/_fields.html.haml
... | ... | @@ -4,9 +4,13 @@ |
4 | 4 | = f.label :name |
5 | 5 | = f.text_field :name |
6 | 6 | |
7 | -%div | |
8 | - = f.label :github_url | |
9 | - = f.text_field :github_url | |
7 | +%fieldset | |
8 | + %legend Links to Codebase | |
9 | + %div | |
10 | + = f.label :github_url | |
11 | + = f.text_field :github_url | |
12 | + = f.label :redmine_url | |
13 | + = f.text_field :redmine_url | |
10 | 14 | |
11 | 15 | %fieldset |
12 | 16 | %legend Notifications | ... | ... |
app/views/notices/_backtrace.html.haml
... | ... | @@ -4,11 +4,7 @@ |
4 | 4 | %th |
5 | 5 | %ul.line-numbers |
6 | 6 | - lines.each do |line| |
7 | - %li | |
8 | - - if line['number'].present? | |
9 | - = (@app.github_url? && Notice.in_app_backtrace_line?(line)) ? link_to_github(@app, line, line['number']) : line['number'] | |
10 | - - else | |
11 | - | |
7 | + %li= line_number_with_link(@app, line) | |
12 | 8 | %td |
13 | 9 | %ul.lines |
14 | 10 | - lines.each do |line| | ... | ... |