summaryrefslogtreecommitdiff
path: root/scripts/pre-commit
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-01-12 19:43:38 +0800
committerLin Jen-Shin <godfat@godfat.org>2018-01-12 19:43:38 +0800
commitcfd75101d19db3235b64b05d7a58616db40f22c6 (patch)
tree6eef1dd8bd6a1ddc8f69ffdf35bf2f9b6771c30c /scripts/pre-commit
parentf4bd9c0b5e1eafe6de855d73bfb606909229f382 (diff)
parentf9579df8617add53424f57c0feedfa601a77e923 (diff)
downloadgitlab-ce-cfd75101d19db3235b64b05d7a58616db40f22c6.tar.gz
Merge remote-tracking branch 'upstream/master' into 1819-override-ce
* upstream/master: (621 commits) Add a note about GitLab QA page objects validator to docs Refactor dispatcher projects blame and blob path Update export message to mention we can download the file from the UI Fix Ctrl+Enter keyboard shortcut saving comment/note edit fix case where tooltip messes up :last-child selector Add reason to keep postgresql 9.2 for CI Remove warning noise in ProjectImportOptions Add changelog entry Add RedirectRoute factory Update Ingress extra cost note to be more generic Fix Rubocop offense Refactor dispatcher project branches path Revert "Revert "Fix Route validation for unchanged path"" Document that we need rsync for backing up Docs: move article "Laravel and Envoy w/ CI/CD" Recommend against the use of EFS Adds Rubocop rule for line break around conditionals Update CHANGELOG.md for 10.1.6 Filter out build traces from logged parameters Refactored project:n* imports in dispatcher.js ...
Diffstat (limited to 'scripts/pre-commit')
-rw-r--r--scripts/pre-commit18
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/pre-commit b/scripts/pre-commit
new file mode 100644
index 00000000000..48935e90a87
--- /dev/null
+++ b/scripts/pre-commit
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# Check if file exists with -f. Check if in in the gdk rook directory.
+if [ ! -f ../GDK_ROOT ]; then
+ echo "Please run pre-commit from gitlab (e.g. gitlab-development-kit/gitlab) root directory."
+ exit 1
+fi
+
+jsfiles=$(git diff --cached --name-only --diff-filter=ACM "*.js" | tr '\n' ' ')
+[ -z "$jsfiles" ] && exit 0
+
+# Prettify all staged .js files
+echo "$jsfiles" | xargs ./node_modules/.bin/prettier --write
+
+# Add back the modified/prettified files to staging
+echo "$jsfiles" | xargs git add
+
+exit 0