From 4dac43f7c969e1e5f88b73e90bfd57d8d0502699 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 12 Dec 2017 20:21:26 +0000 Subject: [PATCH 1/5] Fix duplicated tab completion of branches that exist locally and on the remote (issue --- src/GitTabExpansion.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index a9a2a7c12..d0dbef811 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -359,9 +359,11 @@ function GitTabExpansionInternal($lastBlock, $GitStatus = $null) { # Handles git checkout "^(?:checkout).* (?\S*)$" { - gitBranches $matches['ref'] $true - gitRemoteUniqueBranches $matches['ref'] - gitTags $matches['ref'] + $script:gitBranches = @(gitBranches $matches['ref'] $true) + $script:gitRemoteUniqueBranches = @(gitRemoteUniqueBranches $matches['ref']) + $script:gitTags = @(gitTags $matches['ref']) + # return only unique branches (to eliminate duplicates where the branch exists locally and on the remote) + $script:gitBranches + $script:gitRemoteUniqueBranches + $script:gitTags | Sort-Object -Unique } # Handles git worktree add From 82b84c4f22ef787f2813a2d59f51f1ec790ead74 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 12 Dec 2017 20:28:16 +0000 Subject: [PATCH 2/5] use select-object because of performance and to keep order of arrays the same and the arrays themselves are already ordered --- src/GitTabExpansion.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index d0dbef811..3ca0fc3c5 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -363,7 +363,7 @@ function GitTabExpansionInternal($lastBlock, $GitStatus = $null) { $script:gitRemoteUniqueBranches = @(gitRemoteUniqueBranches $matches['ref']) $script:gitTags = @(gitTags $matches['ref']) # return only unique branches (to eliminate duplicates where the branch exists locally and on the remote) - $script:gitBranches + $script:gitRemoteUniqueBranches + $script:gitTags | Sort-Object -Unique + $script:gitBranches + $script:gitRemoteUniqueBranches + $script:gitTags | Select-Object -Unique } # Handles git worktree add From 111b59a3c749ce9d048b52adbac3ca7104dd6ff9 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 13 Dec 2017 23:42:45 +0000 Subject: [PATCH 3/5] Make comment start with an upper case letter to poke the hanging PR build --- src/GitTabExpansion.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index 3ca0fc3c5..18ffb4c8f 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -362,7 +362,7 @@ function GitTabExpansionInternal($lastBlock, $GitStatus = $null) { $script:gitBranches = @(gitBranches $matches['ref'] $true) $script:gitRemoteUniqueBranches = @(gitRemoteUniqueBranches $matches['ref']) $script:gitTags = @(gitTags $matches['ref']) - # return only unique branches (to eliminate duplicates where the branch exists locally and on the remote) + # Return only unique branches (to eliminate duplicates where the branch exists locally and on the remote) $script:gitBranches + $script:gitRemoteUniqueBranches + $script:gitTags | Select-Object -Unique } From 42e31cc4ae4ddddf0c97f225d0cf9f1125317328 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 14 Dec 2017 07:47:14 +0000 Subject: [PATCH 4/5] Optimise git checkout completion fix by working in pipeline to avoid creating temporary arrays. --- src/GitTabExpansion.ps1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index 18ffb4c8f..48ede2b38 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -359,11 +359,12 @@ function GitTabExpansionInternal($lastBlock, $GitStatus = $null) { # Handles git checkout "^(?:checkout).* (?\S*)$" { - $script:gitBranches = @(gitBranches $matches['ref'] $true) - $script:gitRemoteUniqueBranches = @(gitRemoteUniqueBranches $matches['ref']) - $script:gitTags = @(gitTags $matches['ref']) - # Return only unique branches (to eliminate duplicates where the branch exists locally and on the remote) - $script:gitBranches + $script:gitRemoteUniqueBranches + $script:gitTags | Select-Object -Unique + & { + @(gitBranches $matches['ref'] $true) + @(gitRemoteUniqueBranches $matches['ref']) + @(gitTags $matches['ref']) + # Return only unique branches (to eliminate duplicates where the branch exists locally and on the remote) + } | Select-Object -Unique } # Handles git worktree add From d96a35087759a3f166100e2694cdb7fbe629e6a6 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 14 Dec 2017 17:07:15 +0000 Subject: [PATCH 5/5] Cleanup unnecessary array syntax --- src/GitTabExpansion.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index 48ede2b38..ea8e2f463 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -360,9 +360,9 @@ function GitTabExpansionInternal($lastBlock, $GitStatus = $null) { # Handles git checkout "^(?:checkout).* (?\S*)$" { & { - @(gitBranches $matches['ref'] $true) - @(gitRemoteUniqueBranches $matches['ref']) - @(gitTags $matches['ref']) + gitBranches $matches['ref'] $true + gitRemoteUniqueBranches $matches['ref'] + gitTags $matches['ref'] # Return only unique branches (to eliminate duplicates where the branch exists locally and on the remote) } | Select-Object -Unique }