Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
f9397687
Unverified
Commit
f9397687
authored
Oct 14, 2023
by
Marc Cornellà
Committed by
GitHub
Oct 14, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(git): fix fallback to develop branch if `master` not found (#11966)
parent
f7130bb5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
git.plugin.zsh
plugins/git/git.plugin.zsh
+11
-4
No files found.
plugins/git/git.plugin.zsh
View file @
f9397687
...
@@ -20,26 +20,31 @@ function current_branch() {
...
@@ -20,26 +20,31 @@ function current_branch() {
function
git_develop_branch
()
{
function
git_develop_branch
()
{
command
git rev-parse
--git-dir
&>/dev/null
||
return
command
git rev-parse
--git-dir
&>/dev/null
||
return
local
branch
local
branch
for
branch
in
dev devel development
;
do
for
branch
in
dev devel develop
develop
ment
;
do
if
command
git show-ref
-q
--verify
refs/heads/
$branch
;
then
if
command
git show-ref
-q
--verify
refs/heads/
$branch
;
then
echo
$branch
echo
$branch
return
return
0
fi
fi
done
done
echo
develop
echo
develop
return
1
}
}
# Check if main exists and use instead of master
# Check if main exists and use instead of master
function
git_main_branch
()
{
function
git_main_branch
()
{
command
git rev-parse
--git-dir
&>/dev/null
||
return
command
git rev-parse
--git-dir
&>/dev/null
||
return
local
ref
local
ref
for
ref
in
refs/
{
heads,remotes/
{
origin,upstream
}}
/
{
main,trunk,mainline,default
}
;
do
for
ref
in
refs/
{
heads,remotes/
{
origin,upstream
}}
/
{
main,trunk,mainline,default
,master
}
;
do
if
command
git show-ref
-q
--verify
$ref
;
then
if
command
git show-ref
-q
--verify
$ref
;
then
echo
${
ref
:t
}
echo
${
ref
:t
}
return
return
0
fi
fi
done
done
# If no main branch was found, fall back to master but return error
echo
master
echo
master
return
1
}
}
function
grename
()
{
function
grename
()
{
...
@@ -129,6 +134,8 @@ function gbda() {
...
@@ -129,6 +134,8 @@ function gbda() {
git branch
--no-color
--merged
|
command grep
-vE
"^([+*]|
\s
*(
$(
git_main_branch
)
|
$(
git_develop_branch
)
)
\s
*
$)
"
|
command
xargs git branch
--delete
2>/dev/null
git branch
--no-color
--merged
|
command grep
-vE
"^([+*]|
\s
*(
$(
git_main_branch
)
|
$(
git_develop_branch
)
)
\s
*
$)
"
|
command
xargs git branch
--delete
2>/dev/null
local
default_branch
=
$(
git_main_branch
)
local
default_branch
=
$(
git_main_branch
)
((
!
$?
))
||
default_branch
=
$(
git_develop_branch
)
git
for
-each-ref
refs/heads/
"--format=%(refname:short)"
|
\
git
for
-each-ref
refs/heads/
"--format=%(refname:short)"
|
\
while
read
branch
;
do
while
read
branch
;
do
local
merge_base
=
$(
git merge-base
$default_branch
$branch
)
local
merge_base
=
$(
git merge-base
$default_branch
$branch
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment