mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
Upgraded to 0.84 (#583)
`gig` for editing .gitignore export aliases of `docker.nu` implement `kdh` without helm-diff installed Co-authored-by: agent <agent@nuc>
This commit is contained in:
parent
f2e35e153c
commit
e5cf9b15ae
5 changed files with 62 additions and 39 deletions
|
@ -202,6 +202,11 @@ export def-env gn [
|
|||
}
|
||||
}
|
||||
|
||||
# edit .gitignore
|
||||
export def gig [] {
|
||||
e $"(git rev-parse --show-toplevel)/.gitignore"
|
||||
}
|
||||
|
||||
# git pull, push and switch
|
||||
export def gp [
|
||||
branch?: string@"nu-complete git remote branches"
|
||||
|
@ -228,6 +233,7 @@ export def gp [
|
|||
let remote = if ($remote|is-empty) { 'origin' } else { $remote }
|
||||
let lbs = (git branch | lines | each {|x| $x | str substring 2..})
|
||||
let rbs = (remote_braches | each {|x| $x.1})
|
||||
let prev = (_git_status).branch
|
||||
if $branch in $rbs {
|
||||
if $branch in $lbs {
|
||||
let bmsg = '* both local and remote have the branch'
|
||||
|
@ -236,30 +242,21 @@ export def gp [
|
|||
git branch -u $'($remote)/($branch)' $branch
|
||||
git push --force
|
||||
} else {
|
||||
let prev = (_git_status).branch
|
||||
print $'($bmsg), pull'
|
||||
if $prev != $branch {
|
||||
print $'* switch to ($branch)'
|
||||
git checkout $branch
|
||||
}
|
||||
git pull $m $a
|
||||
if $back_to_prev {
|
||||
git checkout $prev
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let prev = (_git_status).branch
|
||||
print "* local doesn't have that branch, fetch"
|
||||
git checkout -b $branch
|
||||
git fetch $remote $branch
|
||||
git branch -u $'($remote)/($branch)' $branch
|
||||
git pull $m $a -v
|
||||
if $back_to_prev {
|
||||
git checkout $prev
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let prev = (_git_status).branch
|
||||
let bmsg = "* remote doesn't have that branch"
|
||||
let force = (sprb $force [--force])
|
||||
if $branch in $lbs {
|
||||
|
@ -270,9 +267,10 @@ export def gp [
|
|||
git checkout -b $branch
|
||||
}
|
||||
git push $force --set-upstream $remote $branch
|
||||
if $back_to_prev {
|
||||
git checkout $prev
|
||||
}
|
||||
}
|
||||
|
||||
if $back_to_prev {
|
||||
git checkout $prev
|
||||
}
|
||||
|
||||
let s = (_git_status)
|
||||
|
@ -300,7 +298,7 @@ export def ga [
|
|||
if $delete {
|
||||
let c = (sprb $cached [--cached])
|
||||
let f = (sprb $force [--force])
|
||||
git rm $c $f $file
|
||||
git rm $c $f -r $file
|
||||
} else if $restore {
|
||||
let o = (spr [--source $source])
|
||||
let s = (sprb $staged [--staged])
|
||||
|
@ -687,6 +685,6 @@ def git_main_branch [] {
|
|||
| str trim
|
||||
| find --regex 'HEAD .*?[:: ].+'
|
||||
| first
|
||||
| str replace 'HEAD .*?[:: ](.+)' '$1'
|
||||
| str replace --regex 'HEAD .*?[:: ](.+)' '$1'
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue