Commit 35748269 authored by Robert Speicher's avatar Robert Speicher

Use Commits#show instead of Commits#index

Takes tree-ish + path as ID
parent 169f16fb
...@@ -4,18 +4,19 @@ class CommitsController < ApplicationController ...@@ -4,18 +4,19 @@ class CommitsController < ApplicationController
before_filter :project before_filter :project
layout "project" layout "project"
include ExtractsPath
# Authorize # Authorize
before_filter :add_project_abilities before_filter :add_project_abilities
before_filter :authorize_read_project! before_filter :authorize_read_project!
before_filter :authorize_code_access! before_filter :authorize_code_access!
before_filter :require_non_empty_project before_filter :require_non_empty_project
before_filter :load_refs, only: :index # load @branch, @tag & @ref
def index def show
@repo = project.repo @repo = @project.repo
@limit, @offset = (params[:limit] || 40), (params[:offset] || 0) @limit, @offset = (params[:limit] || 40), (params[:offset] || 0)
@commits = @project.commits(@ref, params[:path], @limit, @offset) @commits = @project.commits(@ref, @path, @limit, @offset)
@commits = CommitDecorator.decorate(@commits) @commits = CommitDecorator.decorate(@commits)
respond_to do |format| respond_to do |format|
...@@ -25,26 +26,6 @@ class CommitsController < ApplicationController ...@@ -25,26 +26,6 @@ class CommitsController < ApplicationController
end end
end end
# def show
# result = CommitLoad.new(project, current_user, params).execute
# @commit = result[:commit]
# if @commit
# @suppress_diff = result[:suppress_diff]
# @note = result[:note]
# @line_notes = result[:line_notes]
# @notes_count = result[:notes_count]
# @comments_allowed = true
# else
# return git_not_found!
# end
# if result[:status] == :huge_commit
# render "huge_commit" and return
# end
# end
def patch def patch
@commit = project.commit(params[:id]) @commit = project.commit(params[:id])
...@@ -55,11 +36,4 @@ class CommitsController < ApplicationController ...@@ -55,11 +36,4 @@ class CommitsController < ApplicationController
filename: "#{@commit.id}.patch" filename: "#{@commit.id}.patch"
) )
end end
protected
def load_refs
@ref ||= params[:ref].presence || params[:branch].presence || params[:tag].presence
@ref ||= @ref || @project.try(:default_branch) || 'master'
end
end end
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
= link_to project_tree_path(@project, @project.root_ref) do = link_to project_tree_path(@project, @project.root_ref) do
Files Files
%li{class: commit_tab_class} %li{class: commit_tab_class}
= link_to "Commits", project_commits_path(@project) = link_to "Commits", project_history_path(@project, @project.root_ref)
%li{class: tab_class(:network)} %li{class: tab_class(:network)}
= link_to "Network", graph_project_path(@project) = link_to "Network", graph_project_path(@project)
......
...@@ -159,13 +159,20 @@ Gitlab::Application.routes.draw do ...@@ -159,13 +159,20 @@ Gitlab::Application.routes.draw do
end end
end end
# XXX: WIP
resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
resources :commits, only: [:show], constraints: {id: /.+/}, as: 'history'
resources :blame, only: [:show], constraints: {id: /.+/}
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: /.+/}
resources :commits, only: [:index, :show] do # resources :commits, only: [:show], as: 'history' do
member do # member do
get :patch # get :patch
end # end
end # end
resources :team, controller: 'team_members', only: [:index] resources :team, controller: 'team_members', only: [:index]
resources :team_members resources :team_members
...@@ -184,13 +191,6 @@ Gitlab::Application.routes.draw do ...@@ -184,13 +191,6 @@ Gitlab::Application.routes.draw do
post :preview post :preview
end end
end end
# XXX: WIP
resources :blame, only: [:show], constraints: {id: /.+/}
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 end
root to: "dashboard#index" root to: "dashboard#index"
......
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