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
before_filter :project
layout "project"
include ExtractsPath
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
before_filter :load_refs, only: :index # load @branch, @tag & @ref
def index
@repo = project.repo
def show
@repo = @project.repo
@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)
respond_to do |format|
......@@ -25,26 +26,6 @@ class CommitsController < ApplicationController
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
@commit = project.commit(params[:id])
......@@ -55,11 +36,4 @@ class CommitsController < ApplicationController
filename: "#{@commit.id}.patch"
)
end
protected
def load_refs
@ref ||= params[:ref].presence || params[:branch].presence || params[:tag].presence
@ref ||= @ref || @project.try(:default_branch) || 'master'
end
end
......@@ -8,7 +8,7 @@
= link_to project_tree_path(@project, @project.root_ref) do
Files
%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)}
= link_to "Network", graph_project_path(@project)
......
......@@ -159,13 +159,20 @@ Gitlab::Application.routes.draw do
end
end
# XXX: WIP
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
member do
get :patch
end
end
# resources :commits, only: [:show], as: 'history' do
# member do
# get :patch
# end
# end
resources :team, controller: 'team_members', only: [:index]
resources :team_members
......@@ -184,13 +191,6 @@ Gitlab::Application.routes.draw do
post :preview
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
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