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

repository policy listing by id not working

Open javiplx opened this issue 5 years ago • 3 comments

Describe the bug

The argument --repository-id for az repos policy does not work as expected.

Command Name az repos policy list Extension Name: azure-devops. Version: 0.17.0.

Errors: No policy is listed although there are policies applied to that repositry

To Reproduce:

The two commands below should produce the same output, but only the seconds produces response

az repos policy list --project ${project} -o table --repository-id ${id}
az repos policy list --project ${project} -o table | grep ${id}

Expected Behavior

List the policies for the supplied repository id

Environment Summary

Linux-5.4.0-42-generic-x86_64-with-glibc2.29
Python 3.8.2
Shell: bash

azure-cli 2.0.81 *

Extensions:
azure-devops 0.17.0

javiplx avatar Aug 10 '20 08:08 javiplx

Reproduced with the following versions :

azure-cli                         2.27.2

core                              2.27.2
telemetry                          1.0.6

Extensions:
azure-devops                      0.20.0

Python (Linux) 3.6.10 (default, Aug 23 2021, 03:36:00) 

Mikaciu avatar Sep 02 '21 14:09 Mikaciu

I know it's kinda old, but I came across it only now Try to add --branch flag to the command It worked in my case

Ex: az repos policy list --repository-id <repo_id> --branch <branch_name>

Truzi avatar Feb 14 '22 12:02 Truzi

Adding the --branch flag does workaround this issue, but this should still be considered a bug as you can't list all policies for the repository, regardless of the branch. If the --branch flag is required, then this is not documented in the help for the command. The --branch flag also does not appear to accept a wildcard value.

As a workaround you can filter with jq, but this is not ideal.

az repos policy list | jq '.[] | select(.settings.scope[0].repositoryId == "<REPO_UUID>")'

Xiol avatar Mar 14 '24 14:03 Xiol