Azure / Azure/azure-devops-cli-extension

[Feature Request] Auto detect organization/project should first check config before querying GIT remotes

Open
#1,499 2 comments 0 reactions 0 assignees View on GitHub
Feature
Dominant language
Python
Stars
682
Forks
278
Avg merge
3d 23h
Merged PRs (30d)
3

Description

**Is your feature request related to a problem? Please describe.**
The auto detect of organization/project (if set to true, which is default) will always first try to query the git remote, instead of using the defaults configured with `az devops configure --defaults organization=... project=...`.

I am running into this issue when running the azure devops cli in Azure Pipelines and using a managed identity (that doesn't have permissions necessary on Azure Repos).

**Describe the solution you'd like**
It would make much more sense that first the defaults from the config is used instead of querying git remotes + api calls.

**Additional context**
[view source common/services.py](https://github.com/Azure/azure-devops-cli-extension/blob/a7477b6bc03f7fce18dc26e56352727e50303a39/azure-devops/azext_devops/dev/common/services.py#L337-359)

```python
if organization is None:
if should_detect(detect):
git_info = get_vsts_info_from_current_remote_url()
organization = git_info.uri
vsts_tracking_data.properties[ORG_PICKED_FROM_GIT] = organization is not None
if project is None:
project = git_info.project
vsts_tracking_data.properties[PROJECT_PICKED_FROM_GIT] = project is not None
if repo is None:
repo = git_info.repo
vsts_tracking_data.properties[REPO_PICKED_FROM_GIT] = repo is not None
if organization is None:
organization = _resolve_instance_from_config(organization)
vsts_tracking_data.properties[ORG_PICKED_FROM_CONFIG] = organization is not None
else:
orgFromConfig = _resolve_instance_from_config(organization)
vsts_tracking_data.properties[ORG_IGNORED_FROM_CONFIG] = orgFromConfig is not None
if project is None:
project = _resolve_project_from_config(project, project_required)
vsts_tracking_data.properties[PROJECT_PICKED_FROM_CONFIG] = organization is not None
else:
projectFromConfig = _resolve_project_from_config(project, False)
vsts_tracking_data.properties[PROJECT_IGNORED_FROM_CONFIG] = projectFromConfig is not None
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.