From d028ba1d48f4be1920f7915a5f9cffa59086799c Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Tue, 3 May 2022 16:00:02 +0200
Subject: [PATCH] [bdt dev checkout] install pre-commit hook if config is
 available

---
 bob/devtools/scripts/development.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bob/devtools/scripts/development.py b/bob/devtools/scripts/development.py
index 9fe0618c..f11affaa 100644
--- a/bob/devtools/scripts/development.py
+++ b/bob/devtools/scripts/development.py
@@ -62,6 +62,13 @@ def checkout(ctx, names, use_https, subfolder):
 
             subprocess.check_call(["git", "clone", url, dest])
 
+            # call pre-commit if its configuration exists
+            if os.path.isfile(os.path.join(dest, ".pre-commit-config.yaml")):
+                click.echo(
+                    "Installing pre-commit hooks. Make sure you have pre-commit installed."
+                )
+                subprocess.check_call(["pre-commit", "install"], cwd=dest)
+
 
 @with_plugins(iter_entry_points("bdt.dev.cli"))
 @click.group(
-- 
GitLab