Skip to content

Commit b42f2bd

Browse files
authored
➖ remove gstat dependency from git-aliases (#1020)
I removed `gstat` plugin dependency need by replacing the command. ~~The only problem is that the aliases don't work for the current nushell version~~ Done! fixes #973 and closes #974
1 parent 759218d commit b42f2bd

File tree

2 files changed

+45
-18
lines changed

2 files changed

+45
-18
lines changed

aliases/git/git-aliases.nu

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# returns the name of the current branch
12
export def git_current_branch [] {
2-
(gstat).branch
3+
^git rev-parse --abbrev-ref HEAD
34
}
45

56
export def git_main_branch [] {
@@ -49,22 +50,29 @@ export alias gca = git commit --verbose --all
4950
export alias gca! = git commit --verbose --all --amend
5051
export alias gcan! = git commit --verbose --all --no-edit --amend
5152
export alias gcans! = git commit --verbose --all --signoff --no-edit --amend
52-
export alias gcam = git commit --all --message
53-
export alias gcsm = git commit --signoff --message
53+
export def gcam [message: string] {
54+
git commit --all --message $message
55+
}
56+
export def gcsm [message: string] {
57+
git commit --all --signoff $message
58+
}
5459
export alias gcas = git commit --all --signoff
55-
export alias gcasm = git commit --all --signoff --message
60+
export def gcasm [message: string] {
61+
git commit --all --signoff --message $message
62+
}
5663
export alias gcb = git checkout -b
5764
export alias gcd = git checkout develop
5865
export alias gcf = git config --list
59-
6066
export alias gcl = git clone --recurse-submodules
6167
export alias gclean = git clean --interactive -d
6268
export def gpristine [] {
6369
git reset --hard
6470
git clean -d --force -x
6571
}
6672
export alias gcm = git checkout (git_main_branch)
67-
export alias gcmsg = git commit --message
73+
export def gcmsg [message: string] {
74+
git commit --message $message
75+
}
6876
export alias gco = git checkout
6977
export alias gcor = git checkout --recurse-submodules
7078
export alias gcount = git shortlog --summary --numbered
@@ -73,8 +81,9 @@ export alias gcpa = git cherry-pick --abort
7381
export alias gcpc = git cherry-pick --continue
7482
export alias gcs = git commit --gpg-sign
7583
export alias gcss = git commit --gpg-sign --signoff
76-
export alias gcssm = git commit --gpg-sign --signoff --message
77-
84+
export def gcssm [message: string] {
85+
git commit --gpg-sign --signoff --message $message
86+
}
7887
export alias gd = git diff
7988
export alias gdca = git diff --cached
8089
export alias gdcw = git diff --cached --word-diff
@@ -129,7 +138,12 @@ export def gpoat [] {
129138
}
130139
export alias gpod = git push origin --delete
131140
export alias gpodc = git push origin --delete (git_current_branch)
132-
export alias gpr = git pull --rebase
141+
def "nu-complete git pull rebase" [] {
142+
["false","true","merges","interactive"]
143+
}
144+
export def gpr [rebase_type: string@"nu-complete git pull rebase"] {
145+
git pull --rebase $rebase_type
146+
}
133147
export alias gpu = git push upstream
134148
export alias gpv = git push --verbose
135149

@@ -153,10 +167,16 @@ export alias grhh = git reset --hard
153167
export alias groh = git reset $"origin/(git_current_branch)" --hard
154168
export alias grm = git rm
155169
export alias grmc = git rm --cached
156-
export alias grmv = git remote rename
157-
export alias grrm = git remote remove
170+
export def grmv [remote: string, new_name: string] {
171+
git remote rename $remote $new_name
172+
}
173+
export def grrm [remote: string] {
174+
git remote remove $remote
175+
}
158176
export alias grs = git restore
159-
export alias grset = git remote set-url
177+
export def grset [remote: string, url: string] {
178+
git remote set-url $remote $url
179+
}
160180
export alias grss = git restore --source
161181
export alias grst = git restore --staged
162182
export alias grt = cd (git rev-parse --show-toplevel or echo .)
@@ -194,18 +214,24 @@ export def gtv [] {
194214
export alias glum = git pull upstream (git_main_branch)
195215

196216
export alias gunignore = git update-index --no-assume-unchanged
197-
export alias gup = git pull --rebase
217+
export def gup [rebase_type: string@"nu-complete git pull rebase"] {
218+
git pull --rebase $rebase_type
219+
}
198220
export alias gupv = git pull --rebase --verbose
199221
export alias gupa = git pull --rebase --autostash
200222
export alias gupav = git pull --rebase --autostash --verbose
201223

202224
export alias gwch = git whatchanged -p --abbrev-commit --pretty=medium
203225

204226
export alias gwt = git worktree
205-
export alias gwta = git worktree add
227+
export def gwta [path: path, branch: string] {
228+
git worktree add $path $branch
229+
}
206230
export alias gwtls = git worktree list
207231
export alias gwtmv = git worktree move
208-
export alias gwtrm = git worktree remove
232+
export def gwtm [worktree: string] {
233+
git worktree remove $worktree
234+
}
209235

210236
export alias gam = git am
211237
export alias gamc = git am --continue

custom-completions/git/git-completions.nu

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def "nu-complete git checkout" [] {
6262
| append (nu-complete git remote branches with prefix
6363
| parse "{value}"
6464
| insert description "remote branch")
65+
| append (nu-complete git files | where description != "Untracked" | select value | insert description "git file")
6566
| append (nu-complete git commits all)
6667
| append (nu-complete git files | where description != "Untracked" | select value)
6768
}
@@ -463,7 +464,7 @@ export extern "git commit" [
463464
--dry-run # show paths to be committed without committing
464465
--status # include git-status output in commit message
465466
--no-status # do not include git-status output
466-
--gpg-sign(-S):string # GPG-sign commit
467+
--gpg-sign(-S) # GPG-sign commit
467468
--no-gpg-sign # do not GPG-sign commit
468469
...pathspec: string # commit files matching pathspec
469470
]
@@ -576,7 +577,7 @@ export extern "git bisect reset" [
576577

577578
# Show help for a git subcommand
578579
export extern "git help" [
579-
command: string@"nu-complete git subcommands" # subcommand to show help for
580+
command?: string@"nu-complete git subcommands" # subcommand to show help for
580581
]
581582

582583
# git worktree
@@ -687,7 +688,7 @@ export extern "git clone" [
687688
--single-branch # clone commit history from a single branch
688689
--no-single-Branch # do not clone only one branch
689690
--no-tags # do not clone any tags
690-
--recurse-submodules: string # clone the submodules
691+
--recurse-submodules # clone the submodules. Also accepts paths
691692
--shallow-submodules # shallow clone submodules with depth 1
692693
--no-shallow-submodules # do not shallow clone submodules
693694
--remote-submodules # submodules are updating using their remote tracking branch

0 commit comments

Comments
 (0)