How to use the autohooks.template.PreCommitTemplate 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 / tests / test_template.py View on Github external
def test_should_render_mode_poetry(self):
        path = FakeTemplatePath("$SHEBANG")
        template = PreCommitTemplate(path)
        self.assertEqual(
            template.render(mode=Mode.POETRY),
            "/usr/bin/env -S poetry run python3",
        )
github greenbone / autohooks / tests / test_template.py View on Github external
def test_should_render_mode_undefined(self):
        path = FakeTemplatePath("$SHEBANG")
        template = PreCommitTemplate(path)
        self.assertEqual(
            template.render(mode=Mode.UNDEFINED), "/usr/bin/env python3"
        )
github greenbone / autohooks / tests / test_template.py View on Github external
def test_should_render_mode_unknown(self):
        path = FakeTemplatePath("$SHEBANG")
        template = PreCommitTemplate(path)
        self.assertEqual(
            template.render(mode=Mode.UNDEFINED), "/usr/bin/env python3"
        )
github greenbone / autohooks / tests / test_template.py View on Github external
def test_should_render_mode_pipenv(self):
        path = FakeTemplatePath("$SHEBANG")
        template = PreCommitTemplate(path)
        self.assertEqual(
            template.render(mode=Mode.PIPENV),
            "/usr/bin/env -S pipenv run python3",
        )
github greenbone / autohooks / tests / test_template.py View on Github external
def test_should_use_default_template(self):
        template = PreCommitTemplate()
        self.assertEqual(
            template.render(mode=Mode.PYTHONPATH), DEFAULT_TEMPLATE
        )
github greenbone / autohooks / autohooks / hooks.py View on Github external
def write(self, *, mode: Mode):
        template = PreCommitTemplate()
        pre_commit_hook = template.render(mode=mode)

        self.pre_commit_hook_path.write_text(pre_commit_hook)
        self.pre_commit_hook_path.chmod(0o775)

        self._pre_commit_hook = None
github greenbone / autohooks / autohooks / install.py View on Github external
def get_autohooks_pre_commit_hook(mode: Mode) -> str:
    template = PreCommitTemplate()

    return template.render(mode=mode)