From f27b28478f42eac4d00e1e8602f7dd6011fdac06 Mon Sep 17 00:00:00 2001
From: Chris Pastl <chris@crispybits.app>
Date: Fri, 28 Jul 2023 18:48:39 +0200
Subject: [PATCH] chore(pre-commit): add hooks for spell and lint

---
 .pre-commit-config.yaml | 12 ++++++++++++
 Makefile                |  5 ++++-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 .pre-commit-config.yaml

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..4c8475e
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,12 @@
+repos:
+  - repo: https://github.com/codespell-project/codespell
+    rev: v2.2.5
+    hooks:
+      - id: codespell
+        args: []
+  - repo: local
+    hooks:
+      - id: liquidsoap-check
+        name: liquidsoap-check
+        entry: sh -c 'liquidsoap --check src/engine.liq'
+        language: system
diff --git a/Makefile b/Makefile
index d48a80b..e5cc2e2 100644
--- a/Makefile
+++ b/Makefile
@@ -62,13 +62,16 @@ spell::
 	codespell $(wildcard *.md) docs src tests config contrib
 
 init.app::
-	cp -n config/sample.engine-core.ini config/engine-core.ini
+	cp -n config/sample.engine-core.ini config/engine-core.ini || true
 	mkdir -p audio/fallback
 	mkdir -p audio/playlist
 	mkdir -p audio/source
 
 init.dev:: init.app
 	sudo apt install -y codespell
+	sudo apt install -y pre-commit
+	pre-commit autoupdate
+	pre-commit install
 
 test::
 	(cd tests && liquidsoap engine_test_suite.liq)
-- 
GitLab