Update git.py - added a check to see if branch exists

Forgot to check if a branch existed! Fixed that. Now the script works in both .git repos and other directories.
This commit is contained in:
Shervin Sahba 2019-10-28 22:08:51 -07:00 committed by GitHub
parent 8edea0455d
commit e68c998799
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,15 +67,17 @@ class Segment(ThreadedSegment):
def run(self):
self.stats, self.branch = build_stats()
# Abbreviates master branch to M
if self.powerline.segment_conf("git", "master_is_M"):
if self.branch == "master":
self.branch = "M"
if self.branch:
# Abbreviates master branch to M
if self.powerline.segment_conf("git", "master_is_M"):
if self.branch == "master":
self.branch = "M"
# Truncates branch length
branch_max_length = self.powerline.segment_conf("git", "branch_max_length", -1)
if len(self.branch) > branch_max_length :
self.branch = self.branch[:branch_max_length] + u'\u2026'
# Truncates branch length
branch_max_length = self.powerline.segment_conf("git", "branch_max_length", -1)
if len(self.branch) > branch_max_length :
self.branch = self.branch[:branch_max_length] + u'\u2026'
def add_to_powerline(self):
self.join()