commits_controller.rb 844 Bytes
Newer Older
gitlabhq's avatar
gitlabhq committed
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!
gitlabhq's avatar
gitlabhq committed
9

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

    @commits =
      if search.present?
16
        @repository.find_commits_by_message(search, @ref, @path, @limit, @offset).compact
17 18 19
      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
gitlabhq's avatar
gitlabhq committed
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 }
gitlabhq's avatar
gitlabhq committed
28 29 30
    end
  end
end