BigW Consortium Gitlab

commits_controller.rb 996 Bytes
Newer Older
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 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 committed
23

24 25 26
    @merge_request = @project.merge_requests.opened.
      find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref)

gitlabhq committed
27
    respond_to do |format|
28
      format.html
29
      format.json { pager_json("projects/commits/_commits", @commits.size) }
30
      format.atom { render layout: false }
gitlabhq committed
31 32 33
    end
  end
end