<s> import re <EOL> from collections import namedtuple <EOL> import sublime <EOL> Branch = namedtuple ( "<STR_LIT>" , ( <EOL> "<STR_LIT:name>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT:description>" <EOL> ) ) <EOL> class BranchesMixin ( ) : <EOL> def get_branches ( self ) : <EOL> """<STR_LIT>""" <EOL> stdout = self . git ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> return ( branch <EOL> for branch in ( self . _parse_branch_line ( self , line ) for line in stdout . split ( "<STR_LIT:\n>" ) ) <EOL> if branch ) <EOL> @ staticmethod <EOL> def _parse_branch_line ( self , line ) : <EOL> line = line . strip ( ) <EOL> if not line : <EOL> return None <EOL> pattern = r"<STR_LIT>" <EOL> r"<STR_LIT>" <EOL> match = re . match ( pattern , line ) <EOL> if not match : <EOL> return None <EOL> ( is_active , <EOL> is_remote , <EOL> branch_name , <EOL> commit_hash , <EOL> _ , <EOL> tracking_branch , <EOL> _ , <EOL> tracking_status , <EOL> commit_msg <EOL> ) = match . groups ( ) <EOL> active = bool ( is_active ) <EOL> remote = branch_name . split ( "<STR_LIT:/>" ) [ <NUM_LIT:0> ] if is_remote else None <EOL> savvy_settings = sublime . load_settings ( "<STR_LIT>" ) <EOL> enable_branch_descriptions = savvy_settings . get ( "<STR_LIT>" ) <EOL> hide_description = is_remote or not enable_branch_descriptions <EOL> description = "<STR_LIT>" if hide_description else self . git ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" . format ( branch_name ) , <EOL> throw_on_stderr = False <EOL> ) . strip ( "<STR_LIT:\n>" ) <EOL> return Branch ( <EOL> "<STR_LIT:/>" . join ( branch_name . split ( "<STR_LIT:/>" ) [ <NUM_LIT:1> : ] ) if is_remote else branch_name , <EOL> remote , <EOL> branch_name , <EOL> commit_hash , <EOL> commit_msg , <EOL> tracking_branch , <EOL> tracking_status , <EOL> active , <EOL> description <EOL> ) <EOL> def merge ( self , branch_name ) : <EOL> """<STR_LIT>""" <EOL> self . git ( "<STR_LIT>" , branch_name ) </s>
