summaryrefslogtreecommitdiffstats
path: root/scripts/git
diff options
context:
space:
mode:
authorsyeopite <syeopite@syeopite.dev>2021-06-13 06:40:04 -0700
committersyeopite <syeopite@syeopite.dev>2021-06-13 06:40:04 -0700
commit2e6adfb44a1cb091e10a95f3e4ad2d01a2820b1e (patch)
tree9b2be25d2ad436abd1b8983b8b05ef6273663214 /scripts/git
parentc85c6d0ac5e3961ee574222489147089b1b0e2ee (diff)
downloadinvidious-2e6adfb44a1cb091e10a95f3e4ad2d01a2820b1e.tar.gz
invidious-2e6adfb44a1cb091e10a95f3e4ad2d01a2820b1e.tar.bz2
invidious-2e6adfb44a1cb091e10a95f3e4ad2d01a2820b1e.zip
Add locale-key-propagater and auto linter hooks
Diffstat (limited to 'scripts/git')
-rw-r--r--scripts/git/pre-commit23
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/git/pre-commit b/scripts/git/pre-commit
new file mode 100644
index 00000000..e4a27750
--- /dev/null
+++ b/scripts/git/pre-commit
@@ -0,0 +1,23 @@
+# Useful precomit hooks
+# Please see https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks for instructions on installation.
+
+# Crystal linter
+# This is a modified version of the pre-commit hook from the crystal repo. https://github.com/crystal-lang/crystal/blob/master/scripts/git/pre-commit
+# Please refer to that if you'd like an version that doesn't automatically format staged files.
+changed_cr_files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.cr$')
+if [ ! -z "$changed_cr_files" ]; then
+ if [ -x bin/crystal ]; then
+ # use bin/crystal wrapper when available to run local compiler build
+ bin/crystal tool format $changed_cr_files >&2
+ else
+ crystal tool format $changed_cr_files >&2
+ fi
+
+ git add $changed_cr_files
+fi
+
+# Locale equalizer
+if [ ! -z $(git diff --name-only --cached -- locales/) ]; then
+ crystal run scripts/propagate-new-locale-keys.cr
+ git add locales > /dev/null
+fi \ No newline at end of file