summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStimim Chen <106878+Stimim@users.noreply.github.com>2020-12-03 19:00:56 +0800
committerGitHub <noreply@github.com>2020-12-03 12:00:56 +0100
commit1ac40cd4456230f09bf0258b173304929d118992 (patch)
tree81e09476d2b90eada7770da4fde57506b617fbd5
parent3f8af040e9ed2d940451a5259e9c44308b695e60 (diff)
downloadzsh-1ac40cd4456230f09bf0258b173304929d118992.tar.gz
zsh-1ac40cd4456230f09bf0258b173304929d118992.tar.bz2
zsh-1ac40cd4456230f09bf0258b173304929d118992.zip
fix(git-prompt): make `gitstatus.py` python3-compatible (#9186)
check_output() in get_tagname_or_hash() returns bytes instead of str in python3. Decode the return value to utf-8, this works in both python2 and python3. Co-authored-by: Stimim Chen <stimim@google.com>
-rw-r--r--plugins/git-prompt/gitstatus.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py
index 300365d71..bf3173614 100644
--- a/plugins/git-prompt/gitstatus.py
+++ b/plugins/git-prompt/gitstatus.py
@@ -11,11 +11,11 @@ def get_tagname_or_hash():
"""return tagname if exists else hash"""
# get hash
hash_cmd = ['git', 'rev-parse', '--short', 'HEAD']
- hash_ = check_output(hash_cmd).strip()
+ hash_ = check_output(hash_cmd).decode('utf-8').strip()
# get tagname
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()
+ tags = check_output(tags_cmd).decode('utf-8').split()
if tags:
return tags[0] + ('+' if len(tags) > 1 else '')