<s> '''<STR_LIT>''' <EOL> from provy . core import Role <EOL> from provy . more . debian . package . aptitude import AptitudeRole <EOL> class GitRole ( Role ) : <EOL> '''<STR_LIT>''' <EOL> def provision ( self ) : <EOL> '''<STR_LIT>''' <EOL> with self . using ( AptitudeRole ) as role : <EOL> role . ensure_up_to_date ( ) <EOL> role . ensure_package_installed ( '<STR_LIT>' ) <EOL> def ensure_repository ( self , repo , path , owner = None , branch = None , sudo = True ) : <EOL> '''<STR_LIT>''' <EOL> self . __clone_repository ( path , repo , sudo , owner ) <EOL> self . __checkout_branch ( branch , path , repo , sudo , owner ) <EOL> self . __normalize_ownership ( owner , path ) <EOL> def __normalize_ownership ( self , owner , path ) : <EOL> if owner : <EOL> self . change_path_owner ( path , owner ) <EOL> def __checkout_branch ( self , branch , path , repo , sudo , owner ) : <EOL> branch_name = "<STR_LIT>" % branch <EOL> if branch and not branch_name in self . execute ( "<STR_LIT>" % ( path , path ) , <EOL> sudo = True , stdout = False ) : <EOL> self . log ( "<STR_LIT>" % ( repo , branch ) ) <EOL> self . execute ( '<STR_LIT>' % ( path , path , branch ) , sudo = sudo , user = owner ) <EOL> self . log ( "<STR_LIT>" % ( repo , branch ) ) <EOL> def __clone_repository ( self , path , repo , sudo , owner ) : <EOL> if not self . remote_exists_dir ( path ) : <EOL> self . log ( "<STR_LIT>" % repo ) <EOL> self . execute ( "<STR_LIT>" % ( repo , path ) , sudo = sudo , stdout = False , user = owner ) <EOL> self . log ( "<STR_LIT>" % repo ) </s>
