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
e204c596
Commit
e204c596
authored
Dec 21, 2019
by
lieryan
Committed by
Robby Russell
Dec 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite gitstatus collection to be more robust (#7322)
Fix the finicky parsing logic and just ask git the necessary information directly.
parent
feaee044
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
gitstatus.py
plugins/git-prompt/gitstatus.py
+7
-12
No files found.
plugins/git-prompt/gitstatus.py
View file @
e204c596
...
...
@@ -4,26 +4,21 @@ from __future__ import print_function
import
os
import
sys
import
re
import
shlex
from
subprocess
import
Popen
,
PIPE
,
check_output
def
get_tagname_or_hash
():
"""return tagname if exists else hash"""
cmd
=
'git log -1 --format="
%
h
%
d"'
output
=
check_output
(
shlex
.
split
(
cmd
))
.
decode
(
'utf-8'
)
.
strip
()
hash_
,
tagname
=
None
,
None
# get hash
m
=
re
.
search
(
'
\
(.*
\
)$'
,
output
)
if
m
:
hash_
=
output
[:
m
.
start
()
-
1
]
hash_cmd
=
[
'git'
,
'rev-parse'
,
'--short'
,
'HEAD'
]
hash_
=
check_output
(
hash_cmd
)
.
strip
()
# get tagname
m
=
re
.
search
(
'tag: .*[,
\
)]'
,
output
)
if
m
:
tagname
=
'tags/'
+
output
[
m
.
start
()
+
len
(
'tag: '
):
m
.
end
()
-
1
]
tags_cmd
=
[
'git'
,
'for-each-ref'
,
'--points-at=HEAD'
,
'--count=2'
,
'--sort=-version:refname'
,
'--format=
%
(refname:short)'
,
'refs/tags'
]
tags
=
check_output
(
tags_cmd
)
.
split
()
if
tag
name
:
return
tag
name
.
replace
(
' '
,
''
)
if
tag
s
:
return
tag
s
[
0
]
+
(
'+'
if
len
(
tags
)
>
1
else
''
)
elif
hash_
:
return
hash_
return
None
...
...
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