azure-devops-cli-extension
azure-devops-cli-extension copied to clipboard
[Bug] Passing --auto-complete does not auto-complete if branch policy on merge type is applied
Describe the bug
If you pass auto-complete in az repos pr create command autocomplete appears to be turned on, but the PR does not actually autocomplete when all criteria are met. We have a work item requirement, 2 approvers requirement, and passing build requirement.
To Reproduce Azure Cli Version: 2.0.62
Azure-Devops extension version: 0.4.0
Steps to reproduce the behavior:
- login using az login
- create pr using
az repos pr create --auto-completefrom a branch on git repository - complete all requirements for pr to close
- See that PR does not actually close in browser
Expected behavior PR should merge and complete as soon as the last requirement is met

@sddev-dotnet Can you share some more details to help us look into it..
When you said "autocomplete appears to be turned on" do you see the "Cancel auto-complete" on the top on the portal similar to the screenshot? In that case you should see which policy is blocking the PR from auto completing. Refer the sample screenshot where the reviewers policy is blocking the PR. If the Pull request portal does not look similar to sample image do share what do you see on the portal and were you eventually able to complete the PR manually if it did not complete automatically.
Do you see this issue only when you create a PR from the CLI?
@atbagga Yes I see the Cancel Auto Complete button in the top right, and all of my policies have a green checkmark next to them. This only happens when I turn on autocomplete via the cli (and it also happened with the VSTS cli as well when I was using that). Basically, if I want autocomplete, I have to create the PR without it using the CLI, then go into the portal and turn it on. Otherwise, the PR never merges even after all policies are met.

@sddev-dotnet I tried and it works for me as expected.
Can you share the debug output for the command.
Running it with --debug parameter like az repos pr create --auto-complete --debug
Also share what you see in the UI screen.
Please remove any confidential information from the debug output.
sure, it will take a little bit because we require 2 approvers, so I have to find someone to approve the pr, but I will get this added today. As a side note, we have the following policies turned on: 2 approvers 1 required approver from a group All comments resolved (required) Build passing Linked work item
I will get you an example later today though
Here is an example of a PR that I created with auto-complete enabled but not autocompleting when all of the policies are met:

Thanks! I will try to repro it with similar policies.
Thanks @atbagga I think it may have something to do with the merge strategy (because whenever you click the auto-complete button in the UI it asks you for a merge strategy). In my repo, I have it set to squash by default (and delete branch after merge).
We experience the same issue, but only on some pull requests and not all. (Also with a squash and delete policy). Canceling auto-complete and then using the "complete" button works.
Repro the issue. The merge strategy feature recently introduced in the Pull requests is causing this.
When the Auto-complete options specified do not full fill the merge strategy allowed in the branch policies the PR does not auto complete.
@sddev-dotnet In your case since you do a squash merge you can be unblocked if you use the --squash option by default when setting auto-complete. Since this option was existing even before other merge strategy options were introduced so it will continue to work for you unless the organization chooses to switch to a policy which does not allow squash merge.
@ChristophHornung you can try it too if the branch policy allows squash merge and you set the --squash while setting auto-complete you should be good for now.
If branch policy on merge strategy is applied and it does not allow basic or squash merge, --auto-complete set via CLI will not work.
If branch policy allows the basic merge or squash merge and user sets the --squash option correctly as per policy only then will the PR auto-complete work correctly.

Fix for this is blocked on API dependency.
Fix for this is blocked on API dependency.
Could this be implemented now by maybe drawing parallels to #718?
Fix for this is blocked on API dependency.
Could this be implemented now by maybe drawing parallels to #718?
Short answer is no.
Details: The issue 718 was a change in API object which the python client sends as a dictionary of key value pairs which is extendable without upgrading the python client.
This issue is because Pull request client only understands fixed values in this enum and thus requires the client upgrade.
Since the command is not in preview and the new API/Client is preview and subject to change we cannot take dependency on that client yet for getting this functionality.
Any news on this? Have the necessary APIs been implemented?
Looks like the python client is not available yet for 6.0 version which has the changes.
https://github.com/microsoft/azure-devops-python-api/tree/dev/azure-devops/azure/devops
Looks like the python client is not available yet for 6.0 version which has the changes.
It arrived: :)
- https://github.com/microsoft/azure-devops-python-api/tree/dev/azure-devops/azure/devops/v6_0
- https://github.com/microsoft/azure-devops-python-api/releases/tag/6.0.0b1
Any news?
Version 6.0.0b2 of the Python client was released: https://github.com/microsoft/azure-devops-python-api/releases/tag/6.0.0b2
hi @fdcds ,
Sorry, but the REST API v6.0 is still in preview. We can do a client update only when the APIs are out of preview.
Any news on this? The v6.0 REST API is no longer in preview...
Any new update?