commits_controller.rb 696 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
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
11
    @repo = @project.repository
12
    @limit, @offset = (params[:limit] || 40).to_i, (params[:offset] || 0).to_i
13

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
14
    @commits = @repo.commits(@ref, @path, @limit, @offset)
15
    @note_counts = project.notes.where(commit_id: @commits.map(&:id)).
16
      group(:commit_id).count
gitlabhq's avatar
gitlabhq committed
17 18

    respond_to do |format|
19
      format.html
20
      format.json { pager_json("projects/commits/_commits", @commits.size) }
21
      format.atom { render layout: false }
gitlabhq's avatar
gitlabhq committed
22 23 24
    end
  end
end