From 471c81c5ff4ae54814303a2f887736f01511b7a3 Mon Sep 17 00:00:00 2001 From: sgasse <47532708+sgasse@users.noreply.github.com> Date: Sun, 12 Mar 2023 12:22:52 +0100 Subject: [PATCH] custom-completions: git: Add `git rebase` (#404) Co-authored-by: Simon Gasse --- custom-completions/git/git-completions.nu | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/custom-completions/git/git-completions.nu b/custom-completions/git/git-completions.nu index 54567a3..6645e31 100644 --- a/custom-completions/git/git-completions.nu +++ b/custom-completions/git/git-completions.nu @@ -24,6 +24,13 @@ def "nu-complete git commits" [] { ^git rev-list --all --remotes --pretty=oneline | lines | parse "{value} {description}" } +def "nu-complete git branches and commits" [] { + nu-complete git switchable branches + | parse "{value}" + | insert description Branch + | append (nu-complete git commits) +} + # Check out git branches and files export extern "git checkout" [ ...targets: string@"nu-complete git switchable branches" # name of the branch or files to checkout @@ -161,3 +168,15 @@ export extern "git cherry-pick" [ --abort # Cancel the operation --skip # Skip the current commit and continue with the rest of the sequence ] + +# Rebase the current branch +export extern "git rebase" [ + branch?: string@"nu-complete git branches and commits" # name of the branch to rebase onto + upstream?: string@"nu-complete git branches and commits" # upstream branch to compare against + --continue # restart rebasing process after editing/resolving a conflict + --abort # abort rebase and reset HEAD to original branch + --quit # abort rebase but do not reset HEAD + --interactive(-i) # rebase interactively with list of commits in editor + --onto?: string@"nu-complete git branches and commits" # starting point at which to create the new commits + --root # start rebase from root commit +]