summaryrefslogtreecommitdiffstats
path: root/scripts/git
diff options
context:
space:
mode:
authorTheFrenchGhosty <47571719+TheFrenchGhosty@users.noreply.github.com>2021-06-19 07:38:33 +0000
committerGitHub <noreply@github.com>2021-06-19 07:38:33 +0000
commitf88e5f09b47e45032045bae87749a635c338c560 (patch)
treec41fae07bc2b422568b345ea529bdad9f1f55593 /scripts/git
parent2b9c6c95b1f8b63460fad97bb39777be6ec65051 (diff)
parentd4327329596c7d07392896c61fb3aebf4acb7216 (diff)
downloadinvidious-f88e5f09b47e45032045bae87749a635c338c560.tar.gz
invidious-f88e5f09b47e45032045bae87749a635c338c560.tar.bz2
invidious-f88e5f09b47e45032045bae87749a635c338c560.zip
Merge pull request #2152 from syeopite/hooks-and-scripts
Add scripts to ease development
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