azure-devops-cli-extension
azure-devops-cli-extension copied to clipboard
[Feature Request] `az repos pr create` should allow Azure Repos to dynamically choose targetRef
Is your feature request related to a problem? Please describe.
There is a new feature in Azure Repos where a repository can configure custom target branches. When these branches are configured, the PR create page in the Web UI will dynamically choose a target branch based on the first-parent commit history.
This issue's request is that this behavior becomes enabled in az repos pr create when the user does not specify a target branch in the CLI.
Describe the solution you'd like
I have a working implementation in my fork: see diff here. I started creating a PR but then saw that we needed signoff on the approach.
There are two main pieces here:
- Update the REST API data model to include the new
IgnoreTargetRefAndChooseDynamicallymember to theGitPullRequestobject. Since this is an addition to the object model, it will be included in the POST body of the request to create a PR. Older versions of Azure DevOps Server will ignore this member, but newer versions (and the Azure DevOps cloud service) will recognize it as a signal to ignore theTargetRefvalue and instead enable the new logic, when configured. This parameter was the decision of the Azure Repos team instead of makingTargetRefoptional, which was considered a backwards compatibility break. The currentaz repos pr createlogic only interacts with thev5_0model, but all existing models are updated. Further, the latest released model does not yet have this parameter (introduced in ~September 2024 clients). - When selecting a target ref by falling back to the default ref, indicate that this was a "guess" and not something provided by the user. Then, when this guess occurs, we can set the optional member to indicate that the user has not specified a target and thus the given choice can be ignored.
Additional context
I'm the author of this feature in the Azure Repos backend (and of the linked docs). I assisted several major repositories within Microsoft to configure this setting, including the Windows and Office monorepos. I'm contributing client-side changes to az repos and the dev CLIs as we have users creating PRs with those tools.