1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

gp: run git fetch before git push or git pull (#490)

* gp: run `git fetch` before `git push` or `git pull`

* remove useless else

---------

Co-authored-by: nash <nash@iffy.me>
This commit is contained in:
fj0r 2023-05-14 20:58:02 +08:00 committed by GitHub
parent 632a62f035
commit 194eb30dc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -41,7 +41,9 @@ Pull, push and other related to remote repositories
- `--override` just used to trigger a github actions event (in fact, webhooks can also be used)
- if branch is specified, we assume it is `git fetch`
- unless -u is specified: `git push -u`
- finally, if no branch and above parameters are specified, `git pull` or `git push` will be executed according to the current state.
- finally, if no branch and above parameters are specified
- `git fetch` to update status.
- `git pull` or `git push` will be executed according to the current state.
- if both `ahead` and `behind` exist, only `pull`
### ga

View file

@ -122,6 +122,7 @@ export def gp [
git fetch $remote $branch
}
} else {
git fetch
let s = (_git_status)
if $s.behind > 0 {
let r = if $rebase { [--rebase] } else { [] }
@ -129,8 +130,6 @@ export def gp [
git pull $r $a -v
} else if $s.ahead > 0 {
git push
} else {
git fetch
}
}
}