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

Fix #854 - PowerShell aliases against app with .exe ext doesn't work #855

Merged
merged 2 commits into from
Apr 14, 2021

Conversation

rkeithhill
Copy link
Collaborator

Add RegisteredCommands field to GitTabSettings for debug purposes.

Add RegisteredCommands field to GitTabSettings for debug purposes.
@rkeithhill rkeithhill requested a review from dahlbyk April 10, 2021 19:14
Copy link
Owner

@dahlbyk dahlbyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking, but a few questions/ideas.

@@ -537,10 +538,21 @@ function WriteTabExpLog([string] $Message) {

if (!$UseLegacyTabExpansion -and ($PSVersionTable.PSVersion.Major -ge 6)) {
$cmdNames = "git","tgit","gitk"

# Create regex pattern from $cmdNames: ^(git|git\.exe|tgit|tgit\.exe|gitk|gitk\.exe)$
$cmdNamesPattern = "^($(($cmdNames | ForEach-Object { "${_}|${_}\.exe" }) -join '|'))$"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simpler to just optionally match .exe at the end?

Suggested change
$cmdNamesPattern = "^($(($cmdNames | ForEach-Object { "${_}|${_}\.exe" }) -join '|'))$"
$cmdNamesPattern = "^($($cmdNames -join '|'))(\.exe)?$"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/GitUtils.ps1 Outdated
@@ -442,7 +442,7 @@ function InDotGitOrBareRepoDir([string][ValidateNotNullOrEmpty()]$GitDir) {
}

function Get-AliasPattern($cmd) {
$aliases = @($cmd) + @(Get-Alias | Where-Object { $_.Definition -eq $cmd } | Select-Object -Exp Name)
$aliases = @($cmd) + @(Get-Alias | Where-Object { $_.Definition -match "^($cmd|$cmd\.exe)$" } | Foreach-Object Name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$aliases = @($cmd) + @(Get-Alias | Where-Object { $_.Definition -match "^($cmd|$cmd\.exe)$" } | Foreach-Object Name)
$aliases = @($cmd) + @(Get-Alias | Where-Object { $_.Definition -match "^$cmd(\.exe)?$" } | Foreach-Object Name)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +550 to +552
# Create regex pattern from $funcNames e.g.: ^(Git-Checkout|Git-Switch)$
$funcNamesPattern = "^($($funcNames -join '|'))$"
$cmdNames += Get-Alias | Where-Object { $_.Definition -match $funcNamesPattern } | Foreach-Object Name
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test for helper function alias match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dahlbyk dahlbyk merged commit b79c2dc into master Apr 14, 2021
@dahlbyk dahlbyk deleted the rkeithhill/tab-complete-alias-to-app-with-extension branch April 14, 2021 19:16
@dahlbyk
Copy link
Owner

dahlbyk commented Apr 14, 2021

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants