commit_controller.rb 1.12 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
  # Authorize
6
  before_filter :authorize_download_code!
Robert Speicher's avatar
Robert Speicher committed
7
  before_filter :require_non_empty_project
8
  before_filter :commit
Robert Speicher's avatar
Robert Speicher committed
9 10

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

13 14
    @line_notes = @project.notes.for_commit_id(commit.id).inline
    @branches = @project.repository.branch_names_contains(commit.id)
15
    @tags = @project.repository.tag_names_contains(commit.id)
16
    @diffs = @commit.diffs
17 18 19
    @note = @project.build_commit_note(commit)
    @notes_count = @project.notes.for_commit_id(commit.id).count
    @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

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