jaspernbrouwer / powerline-gitstatus

A Powerline segment for showing the status of a Git working copy
MIT License
383 stars 53 forks source link

Fix the IndexError exception raised by popping an empty list of git status #38

Open taoyl opened 4 years ago

taoyl commented 4 years ago

When returned git status is an empty list, popping it will raise an IndexError exception as follows. So add sanity checking to status before parsing branch status.

2019-12-19 10:38:19,910:ERROR:shell:gitstatus:Exception while computing segment: pop from empty list
Traceback (most recent call last):
  File "/home/taoyl/powerline/powerline/segment.py", line 173, in process_segment
    contents = segment['contents_func'](pl, segment_info)
  File "/home/taoyl/powerline/powerline/segment.py", line 412, in <lambda>
    contents_func = lambda pl, segment_info: _contents_func(pl=pl, segment_info=segment_info, **args)
  File "/home/taoyl/powerline/powerline/segments/powerline_gitstatus/segments.py", line 132, in __call__
    branch, detached, behind, ahead = self.parse_branch(status.pop(0))
IndexError: pop from empty list