def pre_commit(self, git_diff_index):
        """
        Runs the plugin's pre-commit script, passing in the diff.

        ``git_diff_index`` is a :py:class:`jig.diffconvert.GitDiffIndex`
        object.

        The pre-commit script will receive JSON data as standard input (stdin).
        The JSON data is comprised of two main attributes: config and diff.

        The ``config`` attribute represents the configuration for this plugin.
        This is up to the plugin author but the values can be changed by the
        user.

        The ``diff`` attribute is a list of files and changes that have
        occurred to them.  See :py:module:`jig.diffconvert` for
        information on what this object provides.
        """
        # Grab this plugin's settings
        data_in = {
            'config': self.config,
            'files': git_diff_index}

        script = join(self.path, PLUGIN_PRE_COMMIT_SCRIPT)
        ph = Popen([script], stdin=PIPE, stdout=PIPE, stderr=PIPE)

        # Send the data to the script
        stdin = json.dumps(data_in, indent=2, cls=PluginDataJSONEncoder)

        retcode = None
        stdout = ''
        stderr = ''

        try:
            stdout, stderr = ph.communicate(stdin)

            # Convert to unicode
            stdout = stdout.decode('utf-8')
            stderr = stderr.decode('utf-8')

            retcode = ph.returncode
        except __HOLE__ as ose:
            # Generic non-zero retcode that indicates an error
            retcode = 1
            if ose.errno == 32:
                stderr = u'Error: received SIGPIPE from the command'
            else:
                stderr = unicode(ose)

        # And return the relevant stuff
        return retcode, stdout, stderr
dataset/ETHPy150Open robmadole/jig/src/jig/plugins/manager.py/Plugin.pre_commit