azure-devops-cli-extension icon indicating copy to clipboard operation
azure-devops-cli-extension copied to clipboard

[Bug] Passing --auto-complete does not auto-complete if branch policy on merge type is applied

Open sddev-dotnet opened this issue 6 years ago • 20 comments
trafficstars

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:

  1. login using az login
  2. create pr using az repos pr create --auto-complete from a branch on git repository
  3. complete all requirements for pr to close
  4. 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 avatar Apr 18 '19 20:04 sddev-dotnet

image

@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 avatar Apr 20 '19 14:04 atbagga

@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 avatar Apr 20 '19 14:04 sddev-dotnet

image

@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.

atbagga avatar Apr 20 '19 15:04 atbagga

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

sddev-dotnet avatar Apr 20 '19 15:04 sddev-dotnet

Here is an example of a PR that I created with auto-complete enabled but not autocompleting when all of the policies are met: image

sddev-dotnet avatar Apr 23 '19 17:04 sddev-dotnet

Thanks! I will try to repro it with similar policies.

atbagga avatar Apr 23 '19 18:04 atbagga

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).

sddev-dotnet avatar Apr 25 '19 17:04 sddev-dotnet

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.

ChristophHornung avatar May 06 '19 11:05 ChristophHornung

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.

atbagga avatar May 07 '19 18:05 atbagga

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.

image

Fix for this is blocked on API dependency.

atbagga avatar May 07 '19 18:05 atbagga

Fix for this is blocked on API dependency.

Could this be implemented now by maybe drawing parallels to #718?

fdcds avatar Sep 06 '19 11:09 fdcds

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.

atbagga avatar Sep 10 '19 10:09 atbagga

Any news on this? Have the necessary APIs been implemented?

fdcds avatar Dec 03 '19 11:12 fdcds

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

atbagga avatar Dec 03 '19 12:12 atbagga

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

fdcds avatar Dec 16 '19 18:12 fdcds

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

fdcds avatar Jan 23 '20 14:01 fdcds

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.

ishitam8 avatar Mar 12 '20 11:03 ishitam8

Any news on this? The v6.0 REST API is no longer in preview...

siprbaum avatar Sep 10 '22 15:09 siprbaum

Any new update?

devopspractease avatar Aug 26 '23 16:08 devopspractease