8152dc673b14c89dc12e816583e24532ed77e8ae

Author
Marc Cornellà <marc@mcornella.com>
Committer
GitHub <noreply@github.com>
Date

Message

fix(git): move squash-merged branch deletion from `gbda` to `gbds` function (#11991)

Diff

 1diff --git a/plugins/git/README.md b/plugins/git/README.md
 2index a4e9f4c4a42e95a2f6be72e204692a7cb352b133..724965302693e9f6acf770ca25f78221208f9bf7 100644
 3--- a/plugins/git/README.md
 4+++ b/plugins/git/README.md
 5@@ -250,7 +250,8 @@ receive further support.
 6 | `git_develop_branch`     | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise. |
 7 | `git_main_branch`        | Returns the name of the main branch: `main` if it exists, `master` otherwise.                                   |
 8 | `grename <old> <new>`    | Renames branch `<old>` to `<new>`, including on the origin remote.                                              |
 9-| `gbda`                   | Deletes all merged and squash-merged branches                                                                   |
10+| `gbda`                   | Deletes all merged branches                                                                   |
11+| `gbds`                   | Deletes all squash-merged branches (**Note: performance degrades with number of branches**)                     |
12 
13 ### Work in Progress (WIP)
14 
15diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
16index d053a7638fde7cb769b4354863e90de79d2f4d85..48937cb83778c3a0e49ad8f61b511310ef835a58 100644
17--- a/plugins/git/git.plugin.zsh
18+++ b/plugins/git/git.plugin.zsh
19@@ -128,11 +128,13 @@ alias gba='git branch --all'
20 alias gbd='git branch --delete'
21 alias gbD='git branch --delete --force'
22 
23-# Copied and modified from James Roeder (jmaroeder) under MIT License
24-# https://github.com/jmaroeder/plugin-git/blob/216723ef4f9e8dde399661c39c80bdf73f4076c4/functions/gbda.fish
25 function gbda() {
26   git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null
27+}
28 
29+# Copied and modified from James Roeder (jmaroeder) under MIT License
30+# https://github.com/jmaroeder/plugin-git/blob/216723ef4f9e8dde399661c39c80bdf73f4076c4/functions/gbda.fish
31+function gbds() {
32   local default_branch=$(git_main_branch)
33   (( ! $? )) || default_branch=$(git_develop_branch)
34