summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-11-09 17:29:19 +0000
committerNick Thomas <nick@gitlab.com>2018-11-09 17:29:19 +0000
commit9adcd62df3831b7b3bee86e7ee9793b5156fe46b (patch)
treee2e6bedc26d70558bc75cb9bb080d0d991a6faa3
parent32bf2667d26cd13ec4d9c640efb5c1042a946f5b (diff)
parent11dd9d6e1f18b75926a4ae2284dce2343d2b5230 (diff)
downloadgitlab-ce-9adcd62df3831b7b3bee86e7ee9793b5156fe46b.tar.gz
Merge branch 'rs-cherry-pick-api' into 'master'
Resolve possible cherry pick API race condition Closes #53773 See merge request gitlab-org/gitlab-ce!22946
-rw-r--r--changelogs/unreleased/rs-cherry-pick-api.yml5
-rw-r--r--lib/api/commits.rb8
2 files changed, 10 insertions, 3 deletions
diff --git a/changelogs/unreleased/rs-cherry-pick-api.yml b/changelogs/unreleased/rs-cherry-pick-api.yml
new file mode 100644
index 00000000000..ce844dfc939
--- /dev/null
+++ b/changelogs/unreleased/rs-cherry-pick-api.yml
@@ -0,0 +1,5 @@
+---
+title: Resolve possible cherry pick API race condition
+merge_request:
+author:
+type: fixed
diff --git a/lib/api/commits.rb b/lib/api/commits.rb
index 1b228069005..3b8f3fedccf 100644
--- a/lib/api/commits.rb
+++ b/lib/api/commits.rb
@@ -194,11 +194,13 @@ 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