-
-
Notifications
You must be signed in to change notification settings - Fork 803
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 duplicated branch completion for git checkout issue 505 #506
Fix duplicated branch completion for git checkout issue 505 #506
Conversation
…the same and the arrays themselves are already ordered
src/GitTabExpansion.ps1
Outdated
gitBranches $matches['ref'] $true | ||
gitRemoteUniqueBranches $matches['ref'] | ||
gitTags $matches['ref'] | ||
$script:gitBranches = @(gitBranches $matches['ref'] $true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You aren't trying to cache the branches, so you probably shouldn't save them in a script scope variable.
I think using the pipeline like this might be a bit more natural and avoids creating multiple arrays:
& {
gitBranches $matches['ref'] $true
gitRemoteUniqueBranches $matches['ref']
gitTags $matches['ref']
} | Select-Object -Unique
You could use a function instead of the script block like I used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, you're right that this is the more efficient way of doing it.
…creating temporary arrays.
src/GitTabExpansion.ps1
Outdated
& { | ||
@(gitBranches $matches['ref'] $true) | ||
@(gitRemoteUniqueBranches $matches['ref']) | ||
@(gitTags $matches['ref']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't need the surrounding @(...)
on these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted, this was a left over from the previous version when I was using arrays.
I just noticed this is targeting Still wish GitHub supported retargeting PRs... |
Hmm, isn't that what |
Despite the alignment of branch names, we don't use Git Flow. |
Fixes #505 by outputting only unique branches.
Instead of the proposed
Sort-Object -Unique
, I usedSelect-Object -Unique
because:git checkout
, therefore keeping the order as it was before makes sense