diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2018-11-12 09:59:50 -0500 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-11-12 09:59:50 -0500 |
commit | 7e15bc5bd9c2aace0cde3dddf96c2c01e3152c40 (patch) | |
tree | 66e58c0bc51dbd2ea22d4896323b245cf8591d97 /lib/api | |
parent | 21b8cebe06ef679b2fed27d0b5b124d3c2cdc7ed (diff) | |
parent | f93539af26dcc76de97a4e647f75308f3164cbf6 (diff) | |
download | gitlab-ce-52937-remove-feature-flag.tar.gz |
Merge branch 'master' into 52937-remove-feature-flag52937-remove-feature-flag
* master: (49 commits)
Docs: updates docs development guidelines
Upgrade whitequark/parser to 2.5.3.0
Update gems in Gemfile.rails5.lock
Proper markdown table in docs Dangerfile
Fix transient rspec issue
Fix some links and Markdown
Fix link for raising helm chart issues
Implement review comments
Docs: Update Variable naming
Update gitlab-markup gem to avoid binary name collision
Disable usage pings in review apps
Bump Sidekiq and other related gems
Fix minor offenses
Use gitlab-ui in jobs and pipelines
Resolve "GitLab Pages settings regressions"
Remove circular dependency on Redactable in migration
Edits to docs Dangerfile
Fix DashboardHelper reference in spec
Resolve possible cherry pick API race condition
Updates clipboard button with gitlab-ui
...
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/commits.rb | 42 | ||||
-rw-r--r-- | lib/api/services.rb | 9 |
2 files changed, 48 insertions, 3 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb index e59abd3e3d0..3b8f3fedccf 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -194,11 +194,47 @@ module API branch_name: params[:branch] } - result = ::Commits::CherryPickService.new(user_project, current_user, commit_params).execute + result = ::Commits::CherryPickService + .new(user_project, current_user, commit_params) + .execute if result[:status] == :success - branch = find_branch!(params[:branch]) - present user_project.repository.commit(branch.dereferenced_target), with: Entities::Commit + present user_project.repository.commit(result[:result]), + with: Entities::Commit + else + render_api_error!(result[:message], 400) + end + end + + desc 'Revert a commit in a branch' do + detail 'This feature was introduced in GitLab 11.6' + success Entities::Commit + end + params do + requires :sha, type: String, desc: 'Commit SHA to revert' + requires :branch, type: String, desc: 'Target branch name', allow_blank: false + end + post ':id/repository/commits/:sha/revert', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do + authorize_push_to_branch!(params[:branch]) + + commit = user_project.commit(params[:sha]) + not_found!('Commit') unless commit + + find_branch!(params[:branch]) + + commit_params = { + commit: commit, + start_branch: params[:branch], + branch_name: params[:branch] + } + + result = ::Commits::RevertService + .new(user_project, current_user, commit_params) + .execute + + if result[:status] == :success + present user_project.repository.commit(result[:result]), + with: Entities::Commit else render_api_error!(result[:message], 400) end diff --git a/lib/api/services.rb b/lib/api/services.rb index 0ae05ce08f1..1cb3b8a7277 100644 --- a/lib/api/services.rb +++ b/lib/api/services.rb @@ -298,6 +298,14 @@ module API desc: 'Title' } ], + 'discord' => [ + { + required: true, + name: :webhook, + type: String, + desc: 'Discord webhook. e.g. https://discordapp.com/api/webhooks/…' + } + ], 'drone-ci' => [ { required: true, @@ -677,6 +685,7 @@ module API BuildkiteService, CampfireService, CustomIssueTrackerService, + DiscordService, DroneCiService, EmailsOnPushService, ExternalWikiService, |