Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] az repos show should auto-detect --repository via git config #1397

Open
MattKotsenas opened this issue Feb 2, 2024 · 1 comment
Labels
Feature Feature Work required.

Comments

@MattKotsenas
Copy link

Related command

az repos show

Is your feature request related to a problem? Please describe.

I work across many repos, and it's often useful to jump to the Azure DevOps repo that corresponds to a locally cloned repository.

It would be nice if I could run az repos show --open and have the CLI automatically detect the repository from the git config, as it does for --org and --project. Instead, I have to pass the repository name explicitly via the --repository parameter.

Describe the solution you'd like

I would like for --repository to be auto-detected when inside a git repo, as it already is for --organization and --project.

Describe alternatives you've considered

Currently I have a cumbersome PowerShell workaround like this:

az repos show --open --repository "$(((git config --get remote.origin.url) -split '_git/')[-1])"
@MattKotsenas
Copy link
Author

I've never contributed to the repo before, but following the dev setup guide I was able to get a local version of the extension running, and it appears that a change like this should be sufficient:

diff --git a/azure-devops/azext_devops/dev/repos/repository.py b/azure-devops/azext_devops/dev/repos/repository.py
index f5baa86..4b4de04 100644
--- a/azure-devops/azext_devops/dev/repos/repository.py
+++ b/azure-devops/azext_devops/dev/repos/repository.py
@@ -95,7 +95,7 @@ def update_repo(repository, default_branch=None, name=None, organization=None, p
     return repository
 
 
-def show_repo(repository, organization=None, project=None, detect=None, open=False):  # pylint: disable=redefined-builtin
+def show_repo(repository=None, organization=None, project=None, detect=None, open=False):  # pylint: disable=redefined-builtin
     """Get the details of a Git repository.
     :param repository: Name or ID of the repository.
     :type repository: str
@@ -108,7 +108,8 @@ def show_repo(repository, organization=None, project=None, detect=None, open=Fal
         organization=organization,
         project=project,
         project_required=True,
-        repo=repository)
+        repo=repository,
+        repo_required=True)
     git_client = get_git_client(organization)
     repository = git_client.get_repository(project=project, repository_id=repository)
     if open:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Feature Work required.
Projects
None yet
Development

No branches or pull requests

1 participant