#NEWLINE# def pre_commit( self , git_diff_index ) : #NEWLINE# #INDENT# "\n        Runs the plugin's pre-commit script, passing in the diff.\n\n        ``git_diff_index`` is a :py:class:`jig.diffconvert.GitDiffIndex`\n        object.\n\n        The pre-commit script will receive JSON data as standard input (stdin).\n        The JSON data is comprised of two main attributes: config and diff.\n\n        The ``config`` attribute represents the configuration for this plugin.\n        This is up to the plugin author but the values can be changed by the\n        user.\n\n        The ``diff`` attribute is a list of files and changes that have\n        occurred to them.  See :py:module:`jig.diffconvert` for\n        information on what this object provides.\n        " #NEWLINE# data_in = { #NEWLINE# #INDENT# 'config' : self . config , #NEWLINE# 'files' : git_diff_index , #NEWLINE# #UNINDENT# } #NEWLINE# script = join ( self . path , PLUGIN_PRE_COMMIT_SCRIPT ) #NEWLINE# ph = Popen ( [ stdin ] , stdin = PIPE , stdout = PIPE , stderr = PIPE ) #NEWLINE# stdin = json . dumps ( data_in , indent = 2 , cls = PluginDataJSONEncoder ) #NEWLINE# retcode = None #NEWLINE# stdout = '' #NEWLINE# stderr = '' #NEWLINE# try : #NEWLINE# #INDENT# ( stdout , stderr ) = ph . communicate ( stdin ) #NEWLINE# stdout = stdout . decode ( 'utf-8' ) #NEWLINE# stderr = stderr . decode ( 'utf-8' ) #NEWLINE# retcode = ph . returncode #NEWLINE# #UNINDENT# except OSError as ose : #NEWLINE# #INDENT# retcode = 1 #NEWLINE# if ( ose . errno == 32 ) : #NEWLINE# #INDENT# stderr = 'Error: received SIGPIPE from the command' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# stderr = unicode ( ose ) #NEWLINE# #UNINDENT# #UNINDENT# return ( retcode , stdout , stderr )