Skip to content

[Feature Request] az repos pr create should allow Azure Repos to dynamically choose targetRef #1431

Open
@derrickstolee

Description

@derrickstolee

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:

  1. Update the REST API data model to include the new IgnoreTargetRefAndChooseDynamically member to the GitPullRequest object. 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 the TargetRef value and instead enable the new logic, when configured. This parameter was the decision of the Azure Repos team instead of making TargetRef optional, which was considered a backwards compatibility break. The current az repos pr create logic only interacts with the v5_0 model, but all existing models are updated. Further, the latest released model does not yet have this parameter (introduced in ~September 2024 clients).
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureFeature Work required.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions