commits_controller.rb 814 字节
Newer Older
G
gitlabhq 已提交
1 2
require "base64"

3
class Projects::CommitsController < Projects::ApplicationController
4 5
  include ExtractsPath

6 7 8
  before_action :require_non_empty_project
  before_action :assign_ref_vars
  before_action :authorize_download_code!
G
gitlabhq 已提交
9

10
  def show
11
    @limit, @offset = (params[:limit] || 40).to_i, (params[:offset] || 0).to_i
12 13 14 15 16 17 18 19
    search = params[:search]

    @commits =
      if search.present?
        @repository.find_commits_by_message(search).compact
      else
        @repository.commits(@ref, @path, @limit, @offset)
      end
20

21
    @note_counts = project.notes.where(commit_id: @commits.map(&:id)).
22
      group(:commit_id).count
G
gitlabhq 已提交
23 24

    respond_to do |format|
25
      format.html
26
      format.json { pager_json("projects/commits/_commits", @commits.size) }
27
      format.atom { render layout: false }
G
gitlabhq 已提交
28 29 30
    end
  end
end