1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-18 10:22:00 +00:00

feat(git)!: ask for confirmation in gpf alias (#10169)

- Rename `git push --force-with-lease ...` to `gpff`
- Add a y/n confirmation prompt to `gpf` before running `git push --force-with-lease ...`

BREAKING CHANGE: this change adds a confirmation prompt to the `gpf` alias before
running the potentially destructive `git push --force-with-lease` command. If you
want to force-run the command without having to confirm it, run `gpff`.
This commit is contained in:
Marc Cornellà 2024-08-15 16:48:03 +02:00 committed by GitHub
parent d26c4a2766
commit c13795d4c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View file

@ -89,7 +89,7 @@ plugins=(... git)
| `gdnolock` | `git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock"` | | `gdnolock` | `git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock"` |
| `gdt` | `git diff-tree --no-commit-id --name-only -r` | | `gdt` | `git diff-tree --no-commit-id --name-only -r` |
| `gf` | `git fetch` | | `gf` | `git fetch` |
| `gfa` | `git fetch --all --tags --prune` | | `gfa` | `git fetch --all --tags --prune` |
| `gfo` | `git fetch origin` | | `gfo` | `git fetch origin` |
| `gg` | `git gui citool` | | `gg` | `git gui citool` |
| `gga` | `git gui citool --amend` | | `gga` | `git gui citool --amend` |
@ -133,8 +133,10 @@ plugins=(... git)
| `gpd` | `git push --dry-run` | | `gpd` | `git push --dry-run` |
| `gpf!` | `git push --force` | | `gpf!` | `git push --force` |
| `ggf` | `git push --force origin $(current_branch)` | | `ggf` | `git push --force origin $(current_branch)` |
| `gpf` | On Git >= 2.30: `git push --force-with-lease --force-if-includes` | | `gpf` | On Git >= 2.30: after confirmation, `git push --force-with-lease --force-if-includes` |
| `gpf` | On Git < 2.30: `git push --force-with-lease` | | `gpf` | On Git < 2.30: after confirmation, `git push --force-with-lease` |
| `gpff` | On Git >= 2.30: `git push --force-with-lease --force-if-includes` |
| `gpff` | On Git < 2.30: `git push --force-with-lease` |
| `ggfl` | `git push --force-with-lease origin $(current_branch)` | | `ggfl` | `git push --force-with-lease origin $(current_branch)` |
| `gpsup` | `git push --set-upstream origin $(git_current_branch)` | | `gpsup` | `git push --set-upstream origin $(git_current_branch)` |
| `gpsupf` | On Git >= 2.30: `git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes` | | `gpsupf` | On Git >= 2.30: `git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes` |

View file

@ -297,10 +297,13 @@ function ggf() {
} }
compdef _git ggf=git-checkout compdef _git ggf=git-checkout
alias gpf!='git push --force' alias 'gpf!'='git push --force'
is-at-least 2.30 "$git_version" \ is-at-least 2.30 "$git_version" \
&& alias gpf='git push --force-with-lease --force-if-includes' \ && alias gpf='read -k 1 -q "?Continue force-push? [y/N] " && echo && git push --force-with-lease --force-if-includes' \
|| alias gpf='git push --force-with-lease' || alias gpf='read -k 1 -q "?Continue force-push? [y/N] " && echo && git push --force-with-lease'
is-at-least 2.30 "$git_version" \
&& alias gpff='git push --force-with-lease --force-if-includes' \
|| alias gpff='git push --force-with-lease'
function ggfl() { function ggfl() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)" [[ "$#" != 1 ]] && local b="$(git_current_branch)"