Skip to content

Commit

Permalink
Fix Redmine repository links
Browse files Browse the repository at this point in the history
Previously the link would point to the revision overview, where the line
number in the urlmakes no sense. Now it shows the file a t the proper line.
One can still switch to the changes from there with one click.
  • Loading branch information
felixbuenemann authored and arthurnn committed Jan 2, 2014
1 parent 121531c commit 08be2b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/issue_trackers/redmine_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def create_issue(problem, reported_by = nil)
def url_to_file(file_path, line_number = nil)
# alt_project_id let's users specify a different project for tickets / app files.
project = self.alt_project_id.present? ? self.alt_project_id : self.project_id
url = "#{self.account.gsub(/\/$/, '')}/projects/#{project}/repository/revisions/#{app.repository_branch}/changes/#{file_path.sub(/\[PROJECT_ROOT\]/, '').sub(/^\//,'')}"
url = "#{self.account.gsub(/\/$/, '')}/projects/#{project}/repository/revisions/#{app.repository_branch}/entry/#{file_path.sub(/\[PROJECT_ROOT\]/, '').sub(/^\//,'')}"
line_number ? url << "#L#{line_number}" : url
end

Expand Down
6 changes: 3 additions & 3 deletions spec/models/issue_trackers/redmine_tracker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
it "should generate a url where a file with line number can be viewed" do
t = Fabricate(:redmine_tracker, :account => 'http://redmine.example.com', :project_id => "errbit")
expect(t.url_to_file("/example/file")).
to eq 'http://redmine.example.com/projects/errbit/repository/revisions/master/changes/example/file'
to eq 'http://redmine.example.com/projects/errbit/repository/revisions/master/entry/example/file'
expect(t.url_to_file("/example/file", 25)).
to eq 'http://redmine.example.com/projects/errbit/repository/revisions/master/changes/example/file#L25'
to eq 'http://redmine.example.com/projects/errbit/repository/revisions/master/entry/example/file#L25'
end

it "should use the alt_project_id to generate a file/linenumber url, if given" do
t = Fabricate(:redmine_tracker, :account => 'http://redmine.example.com',
:project_id => "errbit",
:alt_project_id => "actual_project")
expect(t.url_to_file("/example/file", 25)).
to eq 'http://redmine.example.com/projects/actual_project/repository/revisions/master/changes/example/file#L25'
to eq 'http://redmine.example.com/projects/actual_project/repository/revisions/master/entry/example/file#L25'
end
end

0 comments on commit 08be2b2

Please sign in to comment.