Use Commits#show instead of Commits#index

Takes tree-ish + path as ID
This commit is contained in:
Robert Speicher 2012-09-20 15:32:00 -04:00
parent 169f16fb32
commit 3574826920
6 changed files with 19 additions and 45 deletions

View file

@ -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