c13795d4c40fe075ec8b4450bb78b65ecf8108b2
Author Marc Cornellà <marc@mcornella.com> Committer GitHub <noreply@github.com> Date 2024-08-15 14:48 UTC
Message 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`.
Diff 1 diff --git a/plugins/git/README.md b/plugins/git/README.md
2 index bcd9aca9699f7804fa2b458f327efcc9b0b39fba..592840f870db328b9fd373a9b15d9a22814ec13d 100644
3 --- a/plugins/git/README.md
4 +++ b/plugins/git/README.md
5 @@ -89,7 +89,7 @@ plugins=(... git)
6 | `gdnolock` | `git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock"` |
7 | `gdt` | `git diff-tree --no-commit-id --name-only -r` |
8 | `gf` | `git fetch` |
9 -| `gfa` | `git fetch --all --tags --prune` |
10 +| `gfa` | `git fetch --all --tags --prune` |
11 | `gfo` | `git fetch origin` |
12 | `gg` | `git gui citool` |
13 | `gga` | `git gui citool --amend` |
14 @@ -133,8 +133,10 @@ plugins=(... git)
15 | `gpd` | `git push --dry-run` |
16 | `gpf!` | `git push --force` |
17 | `ggf` | `git push --force origin $(current_branch)` |
18 -| `gpf` | On Git >= 2.30: `git push --force-with-lease --force-if-includes` |
19 -| `gpf` | On Git < 2.30: `git push --force-with-lease` |
20 +| `gpf` | On Git >= 2.30: after confirmation, `git push --force-with-lease --force-if-includes` |
21 +| `gpf` | On Git < 2.30: after confirmation, `git push --force-with-lease` |
22 +| `gpff` | On Git >= 2.30: `git push --force-with-lease --force-if-includes` |
23 +| `gpff` | On Git < 2.30: `git push --force-with-lease` |
24 | `ggfl` | `git push --force-with-lease origin $(current_branch)` |
25 | `gpsup` | `git push --set-upstream origin $(git_current_branch)` |
26 | `gpsupf` | On Git >= 2.30: `git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes` |
27 diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
28 index 0a26399a2d70e62686adeaf589b9744ce874b820..99f640e88b405327ce5e85ebc3732695f27b1afb 100644
29 --- a/plugins/git/git.plugin.zsh
30 +++ b/plugins/git/git.plugin.zsh
31 @@ -297,10 +297,13 @@ function ggf() {
32 }
33 compdef _git ggf=git-checkout
34
35 -alias gpf!='git push --force'
36 +alias 'gpf!'='git push --force'
37 is-at-least 2.30 "$git_version" \
38 - && alias gpf='git push --force-with-lease --force-if-includes' \
39 - || alias gpf='git push --force-with-lease'
40 + && alias gpf='read -k 1 -q "?Continue force-push? [y/N] " && echo && git push --force-with-lease --force-if-includes' \
41 + || alias gpf='read -k 1 -q "?Continue force-push? [y/N] " && echo && git push --force-with-lease'
42 +is-at-least 2.30 "$git_version" \
43 + && alias gpff='git push --force-with-lease --force-if-includes' \
44 + || alias gpff='git push --force-with-lease'
45
46 function ggfl() {
47 [[ "$#" != 1 ]] && local b="$(git_current_branch)"