Skip to content

Commit

Permalink
git: push - support <src>:<dst>
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Feb 18, 2024
1 parent f77a377 commit 8d138e4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions completers/git_completer/cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
})
}),
)
}

0 comments on commit 8d138e4

Please sign in to comment.