<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import time <EOL> try : <EOL> import git <EOL> except ImportError : <EOL> git = None <EOL> import pypet . pypetexceptions as pex <EOL> def add_commit_variables ( traj , commit ) : <EOL> """<STR_LIT>""" <EOL> git_time_value = time . strftime ( '<STR_LIT>' , time . localtime ( commit . committed_date ) ) <EOL> git_short_name = str ( commit . hexsha [ <NUM_LIT:0> : <NUM_LIT:7> ] ) <EOL> git_commit_name = '<STR_LIT>' % git_short_name <EOL> git_commit_name = '<STR_LIT>' + git_commit_name + git_time_value <EOL> if not traj . f_contains ( '<STR_LIT>' + git_commit_name , shortcuts = False ) : <EOL> git_commit_name += '<STR_LIT:.>' <EOL> traj . f_add_config ( git_commit_name + '<STR_LIT>' , commit . hexsha , <EOL> comment = '<STR_LIT>' ) <EOL> traj . f_add_config ( git_commit_name + '<STR_LIT>' , commit . name_rev , <EOL> comment = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> traj . f_add_config ( git_commit_name + '<STR_LIT>' , <EOL> commit . committed_date , comment = '<STR_LIT>' ) <EOL> traj . f_add_config ( git_commit_name + '<STR_LIT:message>' , str ( commit . message ) , <EOL> comment = '<STR_LIT>' ) <EOL> def make_git_commit ( environment , git_repository , user_message , git_fail ) : <EOL> """<STR_LIT>""" <EOL> repo = git . Repo ( git_repository ) <EOL> index = repo . index <EOL> traj = environment . v_trajectory <EOL> if traj . v_comment : <EOL> commentstr = '<STR_LIT>' % traj . v_comment <EOL> else : <EOL> commentstr = '<STR_LIT>' <EOL> if user_message : <EOL> user_message += '<STR_LIT>' <EOL> message = '<STR_LIT>' % ( user_message , traj . v_name , traj . v_time , commentstr ) <EOL> diff = index . diff ( None ) <EOL> if diff : <EOL> if git_fail : <EOL> raise pex . GitDiffError ( '<STR_LIT>' ) <EOL> repo . git . add ( '<STR_LIT>' ) <EOL> commit = index . commit ( message ) <EOL> new_commit = True <EOL> else : <EOL> commit = repo . commit ( None ) <EOL> new_commit = False <EOL> add_commit_variables ( traj , commit ) <EOL> return new_commit , commit . hexsha </s>
