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

[Bug] git aliases don't work #593

Closed
centreboard opened this issue May 10, 2019 · 11 comments
Closed

[Bug] git aliases don't work #593

centreboard opened this issue May 10, 2019 · 11 comments
Assignees
Labels
Area: ProToCol The bugs under ProToCol Team bug

Comments

@centreboard
Copy link

Describe the bug
Trying to use git aliases results in

environment: line 0: exec: az: not found

To Reproduce
Azure Cli Version: 2.0.64
Azure-Devops extension version: 0.8.0

Steps to reproduce the behaviour:

> az devops configure --use-git-aliases yes
> git pr create
environment: line 0: exec: az: not found

Expected behaviour
git pr should have same behaviour as az repos pr
git repo should have same behaviour as az repos

Additional info
Reproduced on windows in cmd and pwsh.

from .gitconfig

[alias]
	pr = "!f() { exec az repos pr \"$@\"; }; f"
	repo = "!f() { exec az repos \"$@\"; }; f"
@centreboard centreboard added Area: ProToCol The bugs under ProToCol Team bug labels May 10, 2019
@Jaykul
Copy link

Jaykul commented May 17, 2019

The az command in the alias needs a .cmd added to it on Windows:

[alias]
	pr = "!f() { exec az.cmd repos pr \"$@\"; }; f"
	repo = "!f() { exec az.cmd repos \"$@\"; }; f"

@atbagga
Copy link
Collaborator

atbagga commented May 22, 2019

@centreboard @Jaykul How did you install azure cli? Was it using the msi or just a pip install?

@centreboard
Copy link
Author

@atbagga I used the msi

@qzdl
Copy link

qzdl commented May 23, 2019

The file is https://github.com/Azure/azure-devops-cli-extension/blob/master/azure-devops/azext_devops/dev/common/git.py => line 193

def _get_alias_value(command):
    return '!f() { exec az ' + command + ' \"$@\"; }; f'

Encountering this was a bit of a pain

@gauravsaralMs
Copy link
Contributor

@qzdl , @centreboard is this happening when you are trying to use git from git bash?
Then this might be related to an issue in azure cli
Azure/azure-cli#8560

can you confirm if this happens from normal terminal also or just git bash..
Apologies for the questions but this will help us to root cause it correctly.

@centreboard
Copy link
Author

I've been running from powershell/cmd prompts.
az repos pr create works from them.
git pr create only works once I've edited the git config to use az.cmd

@gauravsaralMs
Copy link
Contributor

looks like ultimately git alias is executed with git bash environment only
image

this proves that because cls is not recognized but clear works in cmd (which can't happen in cmd, but happens in bash)

@atbagga
Copy link
Collaborator

atbagga commented May 24, 2019

This is related to Azure CLI MSI not packaging/handling the az bash script. It does work for me on my windows machine since az bash script is picked from the python scripts folder.

One quick fix for this could be to add windows specific hack in setting git aliases as suggested above and use az.cmd instead of az.

I will explore if we can fix the Azure CLI MSI packaging and fix this properly else go with the workaround.

qzdl pushed a commit to qzdl/azure-devops-cli-extension that referenced this issue May 24, 2019
…alias generation to extend support to windows
@qzdl
Copy link

qzdl commented May 24, 2019

@qzdl , @centreboard is this happening when you are trying to use git from git bash?
Then this might be related to an issue in azure cli
Azure/azure-cli#8560

can you confirm if this happens from normal terminal also or just git bash..
Apologies for the questions but this will help us to root cause it correctly.

@gauravsaralMs
This error occurs in powershell/git bash/cmd prompts.
I have no issue with other az commands in PS6

See a hacky fix in the below commit
qzdl@5951357

@atbagga
Copy link
Collaborator

atbagga commented May 27, 2019

@qzdl Thank you for the suggested fix. We have taken the workaround for now until this gets fixed in Azure CLI.
Feel free to raise a PR in the future for similar cases.

@atbagga
Copy link
Collaborator

atbagga commented May 27, 2019

Fix will be available in the next release 0.9.0, scheduled to release in this week.

@atbagga atbagga closed this as completed May 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: ProToCol The bugs under ProToCol Team bug
Projects
None yet
Development

No branches or pull requests

5 participants