ab58594173c04f7fe2155a169d8906ef761ba0fc
- Author
- Max Eisner <4730112+max-ae@users.noreply.github.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
1diff --git a/plugins/git/README.md b/plugins/git/README.md
2index e00f4cf92f39f06f3b2ce3e929e4cb430a292f1e..522257d2dbb2db978351b6b0831eff8784bbbc4a 100644
3--- a/plugins/git/README.md
4+++ b/plugins/git/README.md
5@@ -23,7 +23,7 @@ plugins=(... git)
6 | gb | git branch |
7 | gba | git branch -a |
8 | gbd | git branch -d |
9-| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 git branch -d |
10+| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| command xargs -n 1 git branch -d |
11 | gbD | git branch -D |
12 | gbl | git blame -b -w |
13 | gbnm | git branch --no-merged |
14@@ -49,8 +49,8 @@ plugins=(... git)
15 | gcl | git clone --recurse-submodules |
16 | gclean | git clean -id |
17 | gpristine | git reset --hard && git clean -dffx |
18-| gcm | git checkout $(git_main_branch) |
19-| gcd | git checkout develop |
20+| gcm | git checkout $(git_main_branch) |
21+| gcd | git checkout $(git_develop_branch) |
22 | gcmsg | git commit -m |
23 | gco | git checkout |
24 | gcor | git checkout --recurse-submodules |
25@@ -88,7 +88,7 @@ plugins=(... git)
26 | ghh | git help |
27 | gignore | git update-index --assume-unchanged |
28 | gignored | git ls-files -v \| grep "^[[:lower:]]" |
29-| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
30+| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
31 | gk | gitk --all --branches |
32 | gke | gitk --all $(git log -g --pretty=%h) |
33 | gl | git pull |
34@@ -107,10 +107,10 @@ plugins=(... git)
35 | gloga | git log --oneline --decorate --graph --all |
36 | glp | git log --pretty=\<format\> |
37 | gm | git merge |
38-| gmom | git merge origin/$(git_main_branch) |
39+| gmom | git merge origin/$(git_main_branch) |
40 | gmt | git mergetool --no-prompt |
41 | gmtvim | git mergetool --no-prompt --tool=vimdiff |
42-| gmum | git merge upstream/$(git_main_branch) |
43+| gmum | git merge upstream/$(git_main_branch) |
44 | gma | git merge --abort |
45 | gp | git push |
46 | gpd | git push --dry-run |
47@@ -125,10 +125,10 @@ plugins=(... git)
48 | grb | git rebase |
49 | grba | git rebase --abort |
50 | grbc | git rebase --continue |
51-| grbd | git rebase develop |
52+| grbd | git rebase $(git_develop_branch) |
53 | grbi | git rebase -i |
54-| grbm | git rebase $(git_main_branch) |
55-| grbo | git rebase --onto |
56+| grbm | git rebase $(git_main_branch) |
57+| grbo | git rebase --onto |
58 | grbs | git rebase --skip |
59 | grev | git revert |
60 | grh | git reset |
61@@ -176,7 +176,7 @@ plugins=(... git)
62 | gupv | git pull --rebase -v |
63 | gupa | git pull --rebase --autostash |
64 | gupav | git pull --rebase --autostash -v |
65-| glum | git pull upstream $(git_main_branch) |
66+| glum | git pull upstream $(git_main_branch) |
67 | gwch | git whatchanged -p --abbrev-commit --pretty=medium |
68 | gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" |
69 | gam | git am |
70@@ -214,13 +214,14 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa
71
72 ### Current
73
74-| Command | Description |
75-|:-----------------------|:-----------------------------------------------------------------------------|
76-| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
77-| current_branch | Return the name of the current branch |
78-| git_current_user_name | Returns the `user.name` config value |
79-| git_current_user_email | Returns the `user.email` config value |
80-| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
81+| Command | Description |
82+|:-----------------------|:---------------------------------------------------------------------------------------------------------|
83+| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
84+| current_branch | Return the name of the current branch |
85+| git_current_user_name | Returns the `user.name` config value |
86+| git_current_user_email | Returns the `user.email` config value |
87+| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
88+| git_develop_branch | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
89
90 ### Work in Progress (WIP)
91
92diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
93index 2a7c7290d36be218cdc53add3b5ca40096e83e61..3cd55869245708281cb9e4cb4851fd0c4f90d3d3 100644
94--- a/plugins/git/git.plugin.zsh
95+++ b/plugins/git/git.plugin.zsh
96@@ -42,6 +42,19 @@ function git_main_branch() {
97 echo master
98 }
99
100+# Check for develop and similarly named branches
101+function git_develop_branch() {
102+ command git rev-parse --git-dir &>/dev/null || return
103+ local branch
104+ for branch in dev devel development; do
105+ if command git show-ref -q --verify refs/heads/$branch; then
106+ echo $branch
107+ return
108+ fi
109+ done
110+ echo develop
111+}
112+
113 #
114 # Aliases
115 # (sorted alphabetically)
116@@ -60,7 +73,7 @@ alias gapt='git apply --3way'
117 alias gb='git branch'
118 alias gba='git branch -a'
119 alias gbd='git branch -d'
120-alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d'
121+alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs -n 1 git branch -d'
122 alias gbD='git branch -D'
123 alias gbl='git blame -b -w'
124 alias gbnm='git branch --no-merged'
125@@ -88,7 +101,7 @@ alias gcl='git clone --recurse-submodules'
126 alias gclean='git clean -id'
127 alias gpristine='git reset --hard && git clean -dffx'
128 alias gcm='git checkout $(git_main_branch)'
129-alias gcd='git checkout develop'
130+alias gcd='git checkout $(git_develop_branch)'
131 alias gcmsg='git commit -m'
132 alias gco='git checkout'
133 alias gcor='git checkout --recurse-submodules'
134@@ -227,7 +240,7 @@ alias gra='git remote add'
135 alias grb='git rebase'
136 alias grba='git rebase --abort'
137 alias grbc='git rebase --continue'
138-alias grbd='git rebase develop'
139+alias grbd='git rebase $(git_develop_branch)'
140 alias grbi='git rebase -i'
141 alias grbm='git rebase $(git_main_branch)'
142 alias grbo='git rebase --onto'