Project

General

Profile

Defect #31141 » fix-31141.patch

Mizuki ISHIKAWA, 2019-05-16 03:46

View differences:

app/controllers/repositories_controller.rb
Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}")
unless read_fragment(@cache_key)
@diff = @repository.diff(@path, @rev, @rev_to)
show_error_not_found unless @diff
(show_error_not_found; return) unless @diff
end
@changeset = @repository.find_changeset_by_name(@rev)
@changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil
@diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to)
render :diff, :formats => :html
end
end
config/routes.rb
post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
%w(browse show entry raw annotate diff).each do |action|
%w(browse show entry raw annotate).each do |action|
get "projects/:id/repository/:repository_id/revisions/:rev/#{action}(/*path)",
:controller => 'repositories',
:action => action,
:format => false,
:format => 'html',
:constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/}
end
%w(browse entry raw changes annotate diff).each do |action|
%w(browse entry raw changes annotate).each do |action|
get "projects/:id/repository/:repository_id/#{action}(/*path)",
:controller => 'repositories',
:action => action,
:format => false,
:format => 'html',
:constraints => {:path => /.*/}
end
get "projects/:id/repository/:repository_id/revisions/:rev/diff(/*path)",
:to => 'repositories#diff',
:format => false,
:constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/}
get "projects/:id/repository/:repository_id/diff(/*path)",
:to => 'repositories#diff',
:format => false,
:constraints => {:path => /.*/}
get 'projects/:id/repository/:repository_id/show/*path', :to => 'repositories#show', :format => 'html', :constraints => {:path => /.*/}
get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
test/integration/repositories_git_test.rb
assert_match /\Acommit deff712f05a90d96edbd70facc47d944be5897e3/, response.body
end
def test_get_diff_with_format_text_should_return_html
@repository.fetch_changesets
assert_equal NUM_REV, @repository.changesets.count
get "/projects/subproject1/repository/#{@repository.id}/revisions/deff712f05a90d96edbd70facc47d944be5897e3/diff/sources/watchers_controller.rb", :params => { :format => 'txt' }
assert_response :success
assert a = css_select("a.diff").first
assert_equal 'Unified diff', a.text
get a['href']
assert_response :success
assert_match /\Acommit deff712f05a90d96edbd70facc47d944be5897e3/, response.body
end
else
puts "Git test repository NOT FOUND. Skipping integration tests !!!"
def test_fake; assert true end
test/integration/routing/repositories_test.rb
should_route 'GET /projects/foo/repository/foo/revisions.atom' => 'repositories#revisions', :id => 'foo', :repository_id => 'foo', :format => 'atom'
should_route 'GET /projects/foo/repository/foo/revisions/2457' => 'repositories#revision', :id => 'foo', :repository_id => 'foo', :rev => '2457'
should_route 'GET /projects/foo/repository/foo/revisions/2457/show' => 'repositories#show', :id => 'foo', :repository_id => 'foo', :rev => '2457'
should_route 'GET /projects/foo/repository/foo/revisions/2457/show' => 'repositories#show', :id => 'foo', :repository_id => 'foo', :rev => '2457', :format => 'html'
should_route 'GET /projects/foo/repository/foo/revisions/2457/diff' => 'repositories#diff', :id => 'foo', :repository_id => 'foo', :rev => '2457'
%w(show diff entry raw annotate).each do |action|
%w(show entry raw annotate).each do |action|
@paths.each do |path|
should_route "GET /projects/foo/repository/foo/revisions/2457/#{action}/#{path}" => "repositories##{action}",
:id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path
:id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path, :format => 'html'
end
end
@paths.each do |path|
should_route "GET /projects/foo/repository/foo/revisions/2457/diff/#{path}" => "repositories#diff",
:id => 'foo', :repository_id => 'foo', :rev => '2457', :path => path
end
end
def test_repositories_non_revisions_path_with_repository_id
should_route 'GET /projects/foo/repository/svn/changes' => 'repositories#changes', :id => 'foo', :repository_id => 'svn'
should_route 'GET /projects/foo/repository/svn/changes' => 'repositories#changes', :id => 'foo', :repository_id => 'svn', :format => 'html'
%w(changes diff browse entry raw annotate).each do |action|
%w(changes browse entry raw annotate).each do |action|
@paths.each do |path|
should_route "GET /projects/foo/repository/svn/#{action}/#{path}" => "repositories##{action}",
:id => 'foo', :repository_id => 'svn', :path => path
:id => 'foo', :repository_id => 'svn', :path => path, :format => 'html'
end
end
@paths.each do |path|
should_route "GET /projects/foo/repository/svn/diff/#{path}" => "repositories#diff",
:id => 'foo', :repository_id => 'svn', :path => path
end
end
def test_repositories_related_issues_with_repository_id
(1-1/2)