3

Is it possible to make MR for cherry picked commit through gitlab API? In the gitlab's doc there is only oppotunity to make MR from source branch to target branch.

user3441194
  • 57
  • 1
  • 5

2 Answers2

2

Yes, GitLabs support the creation of Merge Requests via cherry-picking commits.

If you go to any commit (e.g. via Repository->Commits->Select a commit), and click on Options->Cherry-pick, GitLab will present you with this dialog: enter image description here

Hence, you will be able to create a new MR from the cherry-picked commit.

It works similar for cherry-picking the changes of an existing merge request.

Thomas Kainrad
  • 2,542
  • 21
  • 26
  • But I have to use REST API. When we use UI to make MR for cherry-picked commit gitlab makes tmp branch (cherry_pick_SHA), merge fast forward cherry-picked commit to it and then creates MR from source branch (cherry_pick_SHA) to target branch. But what if cherry-picked commit has conflict with target branch. – user3441194 Mar 11 '19 at 18:14
  • Just out of curiosity, why do you have to use the REST API? If there is a conflict with the target branch, merging is not possible and the action will fail, not matter if its through API or UI. You would have to manually resolve the conflicts. Using the REST API, I think you would have to make separate calls for 1. creating a new branch, 2. cherry picking the commit to this branch, 3. creating a merge request from this branch – Thomas Kainrad Mar 12 '19 at 08:39
  • I have to make auto merge of bugfix's commits from exp master to dev branch. So I cherry pick these commits from master to dev. And when merging failed I have to make MR for that commit not entire source branch. As I understood that is not possible. – user3441194 Mar 12 '19 at 16:02
0

Not directly. You would want to use the combination of two parts of the API:

Arty-chan
  • 2,572
  • 1
  • 19
  • 25