BigW Consortium Gitlab

commits_controller.rb 1.07 KB
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)
17
      else
18
        @repository.commits(@ref, path: @path, limit: @limit, offset: @offset)
19
      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.atom { render layout: false }
30 31 32 33 34 35 36 37

      format.json do
        pager_json(
          'projects/commits/_commits',
          @commits.size,
          project: @project,
          ref: @ref)
      end
gitlabhq committed
38 39 40
    end
  end
end