summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-10-06 13:41:16 +0200
committerRémy Coutable <remy@rymai.me>2016-10-06 13:41:16 +0200
commit5bdd8c3e3e7b94dab6dfe80a279764c4d451ca75 (patch)
tree78bd06d3e8e298e72c6a38226a97b669afced3ea /lib/api
parentab18d6b7a9d7e6a9d1f04a7e2c3279fa5d136d89 (diff)
parenta1ee8cf5ad07256807f15590bdb5f56152d55553 (diff)
downloadgitlab-ce-5bdd8c3e3e7b94dab6dfe80a279764c4d451ca75.tar.gz
Merge branch 'mahcsig/gitlab-ce-17350-multi-file-commit'
See !6096.
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/commits.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb
index b4eaf1813d4..14ddc8c9a62 100644
--- a/lib/api/commits.rb
+++ b/lib/api/commits.rb
@@ -29,6 +29,42 @@ module API
present commits, with: Entities::RepoCommit
end
+ desc 'Commit multiple file changes as one commit' do
+ detail 'This feature was introduced in GitLab 8.13'
+ end
+
+ params do
+ requires :id, type: Integer, desc: 'The project ID'
+ requires :branch_name, type: String, desc: 'The name of branch'
+ requires :commit_message, type: String, desc: 'Commit message'
+ requires :actions, type: Array, desc: 'Actions to perform in commit'
+ optional :author_email, type: String, desc: 'Author email for commit'
+ optional :author_name, type: String, desc: 'Author name for commit'
+ end
+
+ post ":id/repository/commits" do
+ authorize! :push_code, user_project
+
+ attrs = declared(params)
+ attrs[:source_branch] = attrs[:branch_name]
+ attrs[:target_branch] = attrs[:branch_name]
+ attrs[:actions].map! do |action|
+ action[:action] = action[:action].to_sym
+ action[:file_path].slice!(0) if action[:file_path] && action[:file_path].start_with?('/')
+ action[:previous_path].slice!(0) if action[:previous_path] && action[:previous_path].start_with?('/')
+ action
+ end
+
+ result = ::Files::MultiService.new(user_project, current_user, attrs).execute
+
+ if result[:status] == :success
+ commit_detail = user_project.repository.commits(result[:result], limit: 1).first
+ present commit_detail, with: Entities::RepoCommitDetail
+ else
+ render_api_error!(result[:message], 400)
+ end
+ end
+
# Get a specific commit of a project
#
# Parameters: