summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJacob Schatz <jschatz1@gmail.com>2018-01-02 15:49:39 -0500
committerJacob Schatz <jschatz1@gmail.com>2018-01-02 15:49:39 -0500
commit981aac02f5700650397ed374f648ca25d55ea156 (patch)
treec6b2fa3e96a69ed38a716381189e648fe547fecd /scripts
parentcbb38fde22267192e614abee2bc740a4794deada (diff)
downloadgitlab-ce-981aac02f5700650397ed374f648ca25d55ea156.tar.gz
Update script to work only when run in the gitlab directory.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/add-code-formatters15
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/add-code-formatters b/scripts/add-code-formatters
index 8e60875e3a6..e6fdac7a8e1 100755
--- a/scripts/add-code-formatters
+++ b/scripts/add-code-formatters
@@ -1,4 +1,15 @@
#!/bin/sh
+if [ ! -f ../GDK_ROOT ]; then
+ echo "Please run script from gitlab (e.g. gitlab-development-kit/gitlab) root directory."
+ exit 1
+fi
-touch ./.git/hooks/pre-commit
-ln -s ./pre-commit .git/hooks/pre-commit
+PRECOMMIT=$(git rev-parse --git-dir)/hooks/pre-commit
+
+if [ -f $PRECOMMIT ]; then
+ echo "Pre-commit script already installed."
+ exit 1
+fi
+
+ln -s ./pre-commit $PRECOMMIT
+echo "Pre-commit script installed successfully"