1

I've been working on a project that has multiple environments (imagine two branches for tests, two for pre-production, and the other two for production, etc) using different database software. Sometimes the code is almost the same, but each one of these environments has its differences. Once it's necessary to make a change in a common file between all these branches, the cherry-picking process is just exhausting.

After a few hours of research, I've found an extension called PR Multi-Cherry-Pick, but the problem is that the extension not only creates the Pull Requests but publishes them. However, one of the team's policies is to only publish a pull request after it's approved in its lower layer (only publish in pre-production after it is approved in both test repositories and so on for production). Besides that, I read the merging solution in a similar question but there's no known common ancestor between all the branches simultaneously.

Is there a way to cherry-pick and create all those PRs as drafts? The use of the extension is not mandatory.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Luann Sapucaia
  • 75
  • 2
  • 12
  • How many cherry-picks and PRs are we talking about ? If each of these branches describes an *environment*, but what you want is to set up the same *version of your code* on each environment, I would suggest using a single branch, and move the specificities of each environment as files or directories within that branch. – LeGEC Apr 22 '21 at 15:29
  • 1
    @LeGEC Thanks for your suggestion. Since it's a huge project that it's already running for our customer, I believe that having all the files in one branch would be heavy and dangerous at the same time, especially because of the tests. Usually, we make changes in one branch and then cherry-pick them to 5 other branches. In this particular case, the main goal is not to set up the same version, but possibly the opposite of it. Most of the time one branch is ahead of the other by several features and it's not the case to publish all those modifications at once. – Luann Sapucaia Apr 22 '21 at 15:52
  • I just understood something : by "cherry-picking" you mean Azures "cherry pick a PR" ? – LeGEC Apr 23 '21 at 08:01

1 Answers1

0

You could use Cherry Picks - Create api and Pull Requests - Create api to achieve what you want.

First, use Cherry Picks - Create api to create Cherry Picks:

POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/cherryPicks?api-version=6.0-preview.1

Body:

{
    "generatedRefName":"refs/heads/TopicBranchName",
    "ontoRefName":"refs/heads/TargetBranchName",
    "source":{
        "pullRequestId":xx
        }
}

Then use Pull Requests - Create api to create PRs as draft:

POST https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=6.0

Body:

{
   "isDraft": true,
   "sourceRefName": "refs/heads/TopicBranchName",
   "targetRefName": "refs/heads/TargetBranchName",
   "title": "cherrypicks"
}
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39