commit_controller.rb 1.3 KB
Newer Older
R
Robert Speicher 已提交
1 2 3
# Controller for a specific Commit
#
# Not to be confused with CommitsController, plural.
4
class Projects::CommitController < Projects::ApplicationController
R
Robert Speicher 已提交
5 6 7 8 9 10
  # Authorize
  before_filter :authorize_read_project!
  before_filter :authorize_code_access!
  before_filter :require_non_empty_project

  def show
11
    result = CommitLoadContext.new(project, current_user, params).execute
R
Robert Speicher 已提交
12 13

    @commit = result[:commit]
14

15 16 17 18
    if @commit.nil?
      git_not_found!
      return
    end
R
Robert Speicher 已提交
19

R
Riyad Preukschas 已提交
20
    @suppress_diff = result[:suppress_diff]
B
Boyan Tabakov 已提交
21
    @force_suppress_diff = result[:force_suppress_diff]
R
Riyad Preukschas 已提交
22 23 24

    @note        = result[:note]
    @line_notes  = result[:line_notes]
25
    @branches    = result[:branches]
R
Riyad Preukschas 已提交
26
    @notes_count = result[:notes_count]
27 28
    @target_type = "Commit"
    @notes = project.notes.for_commit_id(@commit.id).not_inline.fresh
R
Riyad Preukschas 已提交
29 30
    @target_id   = @commit.id

31 32
    @comments_allowed = @reply_allowed = true
    @comments_target  = { noteable_type: 'Commit',
R
Riyad Preukschas 已提交
33
                          commit_id: @commit.id }
34 35 36 37 38 39 40

    respond_to do |format|
      format.html do
        if result[:status] == :huge_commit
          render "huge_commit" and return
        end
      end
R
Robert Speicher 已提交
41

R
Riyad Preukschas 已提交
42
      format.diff  { render text: @commit.to_diff }
R
Riyad Preukschas 已提交
43
      format.patch { render text: @commit.to_patch }
R
Robert Speicher 已提交
44 45 46
    end
  end
end