From b0a5b496640503f63eb8447867d1daedc98cfbaf Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Fri, 2 Oct 2020 16:31:36 +0200 Subject: [PATCH] Add init-project task - add a nox session "init-project" + it installs the pre-commit hooks + being a task, the session is run in the develop environment --- noxfile.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/noxfile.py b/noxfile.py index e083aa7..184e1b5 100644 --- a/noxfile.py +++ b/noxfile.py @@ -2,6 +2,8 @@ Nox provides the following tasks: +- "init-project": install the pre-commit hooks + - "fix-branch-references": adjusts links with git branch references in various files (e.g., Mardown or notebooks) @@ -28,6 +30,16 @@ nox.options.envdir = ".cache/nox" nox.options.error_on_external_run = True +@nox.session(name="init-project", venv_backend="none") +def init_project(session): + """Install the pre-commit hooks.""" + for type_ in ( + "pre-commit", + "pre-merge-commit", + ): + session.run("poetry", "run", "pre-commit", "install", f"--hook-type={type_}") + + @nox.session(name="fix-branch-references", venv_backend="none") def fix_branch_references(_session): """Change git branch references.