starcraftman / zsh-git-prompt

[Active Fork] Informative git prompt for zsh
MIT License
58 stars 15 forks source link

Change compute_stats #7

Closed starcraftman closed 6 years ago

starcraftman commented 6 years ago

Possible improvement, parse git status --porcelain only once. Something similar to below.

# TODO: Use porcelain for status, saves two commands                                                                                                                 
#  conflicts = 0                                                                                                                                                     
#  untracked = 0                                                                                                                                                     
#  staged = 0                                                                                                                                                        
#  changed = 0                                                                                                                                                       
#  for line in run_cmd(['git', 'status', '--porcelain']).splitlines():                                                                                               
    #  if line[0] in ['A', 'M']:                                                                                                                                     
        #  changed += 1                                                                                                                                              
    #  if line[0] in ['A', 'M']:                                                                                                                                     
        #  staged += 1                                                                                                                                               
    #  if line[0:2] == '??':                                                                                                                                         
        #  untracked += 1      
starcraftman commented 6 years ago

Note there may be a double counting of conflicts/changed. Investigate and make a test case to cover.