Browse Source

Provides a pre-commit git hook to lint Go files

feature/android
William Petit 11 months ago
parent
commit
77a779aebe
2 changed files with 23 additions and 0 deletions
  1. 6
    0
      doc/prepa-dev.md
  2. 17
    0
      misc/git-hooks/pre-commit

+ 6
- 0
doc/prepa-dev.md View File

@@ -15,4 +15,10 @@
15 15
 2. Lancer le serveur
16 16
   ```shell
17 17
   make watch
18
+  ```
19
+
20
+3. (Optionnel mais recommandé) Installer le hook Git `pre-commit`
21
+  ```shell
22
+  rm -f .git/hooks/pre-commit.sample
23
+  ln -s "$PWD/misc/git-hooks/pre-commit" .git/hooks/pre-commit
18 24
   ```

+ 17
- 0
misc/git-hooks/pre-commit View File

@@ -0,0 +1,17 @@
1
+#!/bin/bash
2
+
3
+set -eo pipefail
4
+
5
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
6
+CHANGESET=$(git diff --cached --name-only --diff-filter=ACM)
7
+
8
+function lint_go_files {
9
+  echo "Linting modified Go files..."
10
+  ( cd "$DIR/../.." && make LINT_ARGS="--new-from-rev=HEAD~ ./..." lint )
11
+}
12
+
13
+function main {
14
+  lint_go_files
15
+}
16
+
17
+main

Loading…
Cancel
Save