commit_controller.rb 1.11 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
  # Authorize
  before_filter :require_non_empty_project
7
  before_filter :authorize_download_code!
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
    @line_notes = commit.notes(@project).inline
14
    @diffs = @commit.diffs
15
    @note = @project.build_commit_note(commit)
16 17
    @notes_count = commit.notes(@project).count
    @notes = commit.notes(@project).not_inline.fresh
18
    @noteable = @commit
19
    @comments_allowed = @reply_allowed = true
20 21 22 23
    @comments_target  = {
      noteable_type: 'Commit',
      commit_id: @commit.id
    }
24 25

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

32 33 34 35 36 37
  def branches
    @branches = @project.repository.branch_names_contains(commit.id)
    @tags = @project.repository.tag_names_contains(commit.id)
    render layout: false
  end

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