Remove Commits#compare, add CompareController
This commit is contained in:
parent
5a5d214de4
commit
169f16fb32
6 changed files with 53 additions and 21 deletions
|
@ -45,18 +45,6 @@ class CommitsController < ApplicationController
|
|||
# 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
|
||||
@commit = project.commit(params[:id])
|
||||
|
||||
|
|
22
app/controllers/compare_controller.rb
Normal file
22
app/controllers/compare_controller.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
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
|
23
app/views/compare/_head.html.haml
Normal file
23
app/views/compare/_head.html.haml
Normal file
|
@ -0,0 +1,23 @@
|
|||
%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
|
|||
resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
|
||||
|
||||
resources :commits, only: [:index, :show] do
|
||||
collection do
|
||||
get :compare
|
||||
end
|
||||
|
||||
member do
|
||||
get :patch
|
||||
end
|
||||
|
@ -194,6 +190,7 @@ Gitlab::Application.routes.draw do
|
|||
resources :blob, only: [:show], constraints: {id: /.+/}
|
||||
# resources :raw, only: [:show], constraints: {id: /.+/}
|
||||
resources :tree, only: [:show], constraints: {id: /.+/}
|
||||
match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/}
|
||||
end
|
||||
|
||||
root to: "dashboard#index"
|
||||
|
|
|
@ -289,16 +289,11 @@ describe CommitController, "routing" do
|
|||
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
|
||||
# project_commits GET /:project_id/commits(.:format) commits#index
|
||||
# POST /:project_id/commits(.:format) commits#create
|
||||
# project_commit GET /:project_id/commits/:id(.:format) commits#show
|
||||
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
|
||||
get("/gitlabhq/commits/1/patch").should route_to('commits#patch', project_id: 'gitlabhq', id: '1')
|
||||
end
|
||||
|
@ -407,6 +402,13 @@ describe TreeController, "routing" do
|
|||
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
|
||||
#
|
||||
# /:project_id/blame/*path
|
||||
|
|
Loading…
Reference in a new issue