From 8d138e40d29b80bd72a2810f4adf9e90ebc87bd0 Mon Sep 17 00:00:00 2001 From: rsteube Date: Sun, 18 Feb 2024 11:26:48 +0100 Subject: [PATCH] git: push - support : --- completers/git_completer/cmd/push.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/completers/git_completer/cmd/push.go b/completers/git_completer/cmd/push.go index 07bc81f230..10acd74251 100644 --- a/completers/git_completer/cmd/push.go +++ b/completers/git_completer/cmd/push.go @@ -60,12 +60,23 @@ func init() { carapace.Gen(pushCmd).PositionalCompletion( git.ActionRemotes(), carapace.ActionCallback(func(c carapace.Context) carapace.Action { - if pushCmd.Flag("set-upstream").Changed { + if pushCmd.Flag("set-upstream").Changed && c.Value == "" { // if set-upstream is set the desired remote branch is likely named the same as the current return git.ActionCurrentBranch() - } else { - return git.ActionLocalBranches() } + + return carapace.ActionMultiPartsN(":", 2, func(c carapace.Context) carapace.Action { + switch len(c.Parts) { + case 0: + return git.ActionRefs(git.RefOption{ + LocalBranches: true, + HeadCommits: 1, + Tags: true, + }).NoSpace() + default: + return git.ActionRemoteBranchNames(c.Args[0]) + } + }) }), ) }