Commit 169f16fb authored by Robert Speicher's avatar Robert Speicher

Remove Commits#compare, add CompareController

parent 5a5d214d
...@@ -45,18 +45,6 @@ class CommitsController < ApplicationController ...@@ -45,18 +45,6 @@ class CommitsController < ApplicationController
# end # end
# end # end
def compare
result = Commit.compare(project, params[:from], params[:to])
@commits = result[:commits]
@commit = result[:commit]
@diffs = result[:diffs]
@refs_are_same = result[:same]
@line_notes = []
@commits = CommitDecorator.decorate(@commits)
end
def patch def patch
@commit = project.commit(params[:id]) @commit = project.commit(params[:id])
......
class CompareController < ApplicationController
before_filter :project
layout "project"
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
def show
result = Commit.compare(project, params[:from], params[:to])
@commits = result[:commits]
@commit = result[:commit]
@diffs = result[:diffs]
@refs_are_same = result[:same]
@line_notes = []
@commits = CommitDecorator.decorate(@commits)
end
end
%ul.nav.nav-tabs
%li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'}
%li{class: "#{'active' if current_page?(project_commits_path(@project)) }"}
= link_to project_commits_path(@project) do
Commits
%li{class: "#{'active' if current_page?(compare_project_commits_path(@project)) }"}
= link_to compare_project_commits_path(@project) do
Compare
%li{class: "#{branches_tab_class}"}
= link_to project_repository_path(@project) do
Branches
%span.badge= @project.repo.branch_count
%li{class: "#{'active' if current_page?(tags_project_repository_path(@project)) }"}
= link_to tags_project_repository_path(@project) do
Tags
%span.badge= @project.repo.tag_count
- if current_page?(project_commits_path(@project)) && current_user.private_token
%li.right
%span.rss-icon
= link_to project_commits_path(@project, :atom, { private_token: current_user.private_token, ref: @ref }), title: "Feed" do
= image_tag "rss_ui.png", title: "feed"
...@@ -162,10 +162,6 @@ Gitlab::Application.routes.draw do ...@@ -162,10 +162,6 @@ Gitlab::Application.routes.draw do
resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
resources :commits, only: [:index, :show] do resources :commits, only: [:index, :show] do
collection do
get :compare
end
member do member do
get :patch get :patch
end end
...@@ -194,6 +190,7 @@ Gitlab::Application.routes.draw do ...@@ -194,6 +190,7 @@ Gitlab::Application.routes.draw do
resources :blob, only: [:show], constraints: {id: /.+/} resources :blob, only: [:show], constraints: {id: /.+/}
# resources :raw, only: [:show], constraints: {id: /.+/} # resources :raw, only: [:show], constraints: {id: /.+/}
resources :tree, only: [:show], constraints: {id: /.+/} resources :tree, only: [:show], constraints: {id: /.+/}
match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/}
end end
root to: "dashboard#index" root to: "dashboard#index"
......
...@@ -289,16 +289,11 @@ describe CommitController, "routing" do ...@@ -289,16 +289,11 @@ describe CommitController, "routing" do
end end
end end
# compare_project_commits GET /:project_id/commits/compare(.:format) commits#compare
# patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch # patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch
# project_commits GET /:project_id/commits(.:format) commits#index # project_commits GET /:project_id/commits(.:format) commits#index
# POST /:project_id/commits(.:format) commits#create # POST /:project_id/commits(.:format) commits#create
# project_commit GET /:project_id/commits/:id(.:format) commits#show # project_commit GET /:project_id/commits/:id(.:format) commits#show
describe CommitsController, "routing" do describe CommitsController, "routing" do
it "to #compare" do
get("/gitlabhq/commits/compare").should route_to('commits#compare', project_id: 'gitlabhq')
end
it "to #patch" do it "to #patch" do
get("/gitlabhq/commits/1/patch").should route_to('commits#patch', project_id: 'gitlabhq', id: '1') get("/gitlabhq/commits/1/patch").should route_to('commits#patch', project_id: 'gitlabhq', id: '1')
end end
...@@ -407,6 +402,13 @@ describe TreeController, "routing" do ...@@ -407,6 +402,13 @@ describe TreeController, "routing" do
end end
end end
describe CompareController, "routing" do
it "to #show" do
get("/gitlabhq/compare/master...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'master', to: 'stable')
get("/gitlabhq/compare/issue/1234...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable')
end
end
# TODO: Pending # TODO: Pending
# #
# /:project_id/blame/*path # /:project_id/blame/*path
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment