How to use the autohooks.utils.GitError function in autohooks

To help you get started, we’ve selected a few autohooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github greenbone / autohooks / autohooks / utils.py View on Github external
def exec_git(*args, ignore_errors=False):
    try:
        cmd_args = ['git']
        cmd_args.extend(args)
        output = subprocess.check_output(cmd_args)
        return output.decode()
    except subprocess.CalledProcessError as e:
        if ignore_errors:
            return ''
        raise GitError(e.returncode, e.cmd, e.output, e.stderr)
github greenbone / autohooks / autohooks / api / git.py View on Github external
# save formatting changes
            formatted_tree = _write_tree()

            self.restore_working_tree()

            # restore index
            # formatted_tree will be the same as index if no changes are applied
            _read_tree(formatted_tree)

            if formatted_tree != self.index:
                # create diff between index and formatted_tree
                patch = _get_tree_diff(self.index, formatted_tree)
                try:
                    # apply diff to working tree
                    _apply_diff(patch)
                except GitError as e:
                    print(
                        'Found conflicts between plugin and local changes. '
                        'Plugin changes will be ignored for conflicted hunks.',
                        e,
                    )

                    rootpath = get_project_root_path()
                    for path in rootpath.glob('*.rej'):
                        path.unlink()