commit_controller.rb 1.09 KB
Newer Older
Robert Speicher's avatar
Robert Speicher committed
1 2 3
# Controller for a specific Commit
#
# Not to be confused with CommitsController, plural.
4
class Projects::CommitController < Projects::ApplicationController
Robert Speicher's avatar
Robert Speicher committed
5 6 7 8
  # Authorize
  before_filter :authorize_read_project!
  before_filter :authorize_code_access!
  before_filter :require_non_empty_project
9
  before_filter :commit
Robert Speicher's avatar
Robert Speicher committed
10 11

  def show
12
    return git_not_found! unless @commit
Robert Speicher's avatar
Robert Speicher committed
13

14
    @line_notes = project.notes.for_commit_id(commit.id).inline
15
    @branches = project.repository.branch_names_contains(commit.id)
16
    @diffs = @commit.diffs
17 18
    @note = project.build_commit_note(commit)
    @notes_count = project.notes.for_commit_id(commit.id).count
19
    @notes = project.notes.for_commit_id(@commit.id).not_inline.fresh
20
    @noteable = @commit
21
    @comments_allowed = @reply_allowed = true
22 23 24 25
    @comments_target  = {
      noteable_type: 'Commit',
      commit_id: @commit.id
    }
26 27

    respond_to do |format|
28
      format.html
29
      format.diff  { render text: @commit.to_diff }
30
      format.patch { render text: @commit.to_patch }
Robert Speicher's avatar
Robert Speicher committed
31 32
    end
  end
33 34 35 36

  def commit
    @commit ||= project.repository.commit(params[:id])
  end
Robert Speicher's avatar
Robert Speicher committed
37
end