diff options
author | Marc Siegfriedt <marc@techaccelerator.com> | 2016-08-29 23:58:32 +0000 |
---|---|---|
committer | Marc Siegfriedt <marc@techaccelerator.com> | 2016-10-05 17:42:52 +0000 |
commit | a1ee8cf5ad07256807f15590bdb5f56152d55553 (patch) | |
tree | 9f90bc8f0d3c5d65e9b8778bc9d80e4ecd8855dd /lib/api/commits.rb | |
parent | 4bc27cd17b304abce01fad1fce56fce32a4ee099 (diff) | |
download | gitlab-ce-a1ee8cf5ad07256807f15590bdb5f56152d55553.tar.gz |
multi-file commit
add docs and tests - add additional validation
allow move without content
updated response
Diffstat (limited to 'lib/api/commits.rb')
-rw-r--r-- | lib/api/commits.rb | 36 |
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: |