2011-10-08 17:36:38 -04:00
|
|
|
require "base64"
|
|
|
|
|
2013-06-23 12:47:22 -04:00
|
|
|
class Projects::CommitsController < Projects::ApplicationController
|
2012-09-20 15:32:00 -04:00
|
|
|
include ExtractsPath
|
|
|
|
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :require_non_empty_project
|
|
|
|
before_action :assign_ref_vars
|
|
|
|
before_action :authorize_download_code!
|
2017-07-25 03:40:23 -04:00
|
|
|
before_action :set_commits
|
2011-10-08 17:36:38 -04:00
|
|
|
|
2012-09-20 15:32:00 -04:00
|
|
|
def show
|
2017-06-21 09:48:12 -04:00
|
|
|
@note_counts = project.notes.where(commit_id: @commits.map(&:id))
|
|
|
|
.group(:commit_id).count
|
2011-10-08 17:36:38 -04:00
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
@merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened
|
|
|
|
.find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref)
|
2016-02-01 18:43:51 -05:00
|
|
|
|
2011-10-08 17:36:38 -04:00
|
|
|
respond_to do |format|
|
2014-10-07 12:52:16 -04:00
|
|
|
format.html
|
2017-06-12 13:21:13 -04:00
|
|
|
format.atom { render layout: 'xml.atom' }
|
2016-10-21 04:22:43 -04:00
|
|
|
|
|
|
|
format.json do
|
|
|
|
pager_json(
|
|
|
|
'projects/commits/_commits',
|
|
|
|
@commits.size,
|
|
|
|
project: @project,
|
|
|
|
ref: @ref)
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
end
|
2017-07-25 03:40:23 -04:00
|
|
|
|
|
|
|
def signatures
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
signatures: @commits.select(&:has_signature?).map do |commit|
|
|
|
|
{
|
|
|
|
commit_sha: commit.sha,
|
|
|
|
html: view_to_html_string('projects/commit/_signature', signature: commit.signature)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_commits
|
|
|
|
@limit, @offset = (params[:limit] || 40).to_i, (params[:offset] || 0).to_i
|
|
|
|
search = params[:search]
|
|
|
|
|
|
|
|
@commits =
|
|
|
|
if search.present?
|
|
|
|
@repository.find_commits_by_message(search, @ref, @path, @limit, @offset)
|
|
|
|
else
|
|
|
|
@repository.commits(@ref, path: @path, limit: @limit, offset: @offset)
|
|
|
|
end
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|