From 1d7875386059cb880e8ea8766359e87c42ff8ec6 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Wed, 20 Dec 2017 12:09:22 -0500 Subject: Initial install --- scripts/pre-commit | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 scripts/pre-commit (limited to 'scripts') diff --git a/scripts/pre-commit b/scripts/pre-commit new file mode 100644 index 00000000000..e3ff5927922 --- /dev/null +++ b/scripts/pre-commit @@ -0,0 +1,11 @@ +#!/bin/sh +jsfiles=$(git diff --cached --name-only --diff-filter=ACM "*.js" "*.jsx" | 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 \ No newline at end of file -- cgit v1.2.1 From 39efc5c80c132657eaf0e1e4704b9e6f76c94d89 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Wed, 20 Dec 2017 15:19:09 -0500 Subject: Remove JSX since we don't use it. --- scripts/pre-commit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/pre-commit b/scripts/pre-commit index e3ff5927922..210e349fe64 100644 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -1,5 +1,5 @@ #!/bin/sh -jsfiles=$(git diff --cached --name-only --diff-filter=ACM "*.js" "*.jsx" | tr '\n' ' ') +jsfiles=$(git diff --cached --name-only --diff-filter=ACM "*.js" | tr '\n' ' ') [ -z "$jsfiles" ] && exit 0 # Prettify all staged .js files -- cgit v1.2.1 From 6f45cbd197b055c1ac18b32fa612b1b462f631b0 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Wed, 20 Dec 2017 15:29:27 -0500 Subject: Add script to enable code formatters --- scripts/add-code-formatters | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 scripts/add-code-formatters (limited to 'scripts') diff --git a/scripts/add-code-formatters b/scripts/add-code-formatters new file mode 100755 index 00000000000..6a22c9a3866 --- /dev/null +++ b/scripts/add-code-formatters @@ -0,0 +1,4 @@ +#!/bin/sh + +touch ./.git/hooks/pre-commit +ln -s -f ./pre-commit .git/hooks/pre-commit \ No newline at end of file -- cgit v1.2.1 From b3b7d12496fda8680a8764701107e819d253fb86 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Wed, 20 Dec 2017 15:48:45 -0500 Subject: Add changelog and newlines --- scripts/add-code-formatters | 2 +- scripts/pre-commit | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/add-code-formatters b/scripts/add-code-formatters index 6a22c9a3866..583676be67c 100755 --- a/scripts/add-code-formatters +++ b/scripts/add-code-formatters @@ -1,4 +1,4 @@ #!/bin/sh touch ./.git/hooks/pre-commit -ln -s -f ./pre-commit .git/hooks/pre-commit \ No newline at end of file +ln -s -f ./pre-commit .git/hooks/pre-commit diff --git a/scripts/pre-commit b/scripts/pre-commit index 210e349fe64..380cc8d9022 100644 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -8,4 +8,4 @@ echo "$jsfiles" | xargs ./node_modules/.bin/prettier --write # Add back the modified/prettified files to staging echo "$jsfiles" | xargs git add -exit 0 \ No newline at end of file +exit 0 -- cgit v1.2.1 From 060bceeacb899b57e4a3255e5610257ca8c28b67 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Wed, 20 Dec 2017 15:54:21 -0500 Subject: Remove `-f` to not ruin other people's existing pre-commit files. --- scripts/add-code-formatters | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/add-code-formatters b/scripts/add-code-formatters index 583676be67c..8e60875e3a6 100755 --- a/scripts/add-code-formatters +++ b/scripts/add-code-formatters @@ -1,4 +1,4 @@ #!/bin/sh touch ./.git/hooks/pre-commit -ln -s -f ./pre-commit .git/hooks/pre-commit +ln -s ./pre-commit .git/hooks/pre-commit -- cgit v1.2.1 From f20581773a12b5653ad43d9e908d756935dcf62c Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Sat, 23 Dec 2017 12:53:13 +1100 Subject: Return exception messages in scripts/lint-changelog-yaml --- scripts/lint-changelog-yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/lint-changelog-yaml b/scripts/lint-changelog-yaml index cce5f1c7667..6553e02ffca 100755 --- a/scripts/lint-changelog-yaml +++ b/scripts/lint-changelog-yaml @@ -8,11 +8,13 @@ invalid_changelogs = Dir['changelogs/**/*'].reject do |changelog| begin YAML.load_file(changelog) - rescue + rescue => exception + puts exception end end if invalid_changelogs.any? + puts puts "Invalid changelogs found!\n" puts invalid_changelogs.sort exit 1 -- cgit v1.2.1 From ef82cbef90c59a8d1d59f05d4acf75a2ecbb42c9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 23 Dec 2017 14:18:39 +0000 Subject: Remove security checks from static analysis and add sast job --- scripts/static-analysis | 2 -- 1 file changed, 2 deletions(-) (limited to 'scripts') diff --git a/scripts/static-analysis b/scripts/static-analysis index 51a2fd81a79..2a2bc67800d 100755 --- a/scripts/static-analysis +++ b/scripts/static-analysis @@ -3,12 +3,10 @@ require ::File.expand_path('../lib/gitlab/popen', __dir__) tasks = [ - %w[bundle exec bundle-audit check --update], %w[bundle exec rake config_lint], %w[bundle exec rake flay], %w[bundle exec rake haml_lint], %w[bundle exec rake scss_lint], - %w[bundle exec rake brakeman], %w[bundle exec license_finder], %w[yarn run eslint], %w[bundle exec rubocop --parallel], -- cgit v1.2.1 From ad88e3f88d2ac287f5a95952f95da4feae90944e Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Wed, 27 Dec 2017 05:41:28 -0800 Subject: Fix `rake db:seed_fu` not doing anything in CI The default behavior of seed_fu is to load the fixtures using the RAILS_ENV environment. In CI, since we set RAILS_ENV=test, nothing is ever loaded. Instead of `rake db:seed_fu`, use `rake gitlab:setup`, which sets up MySQL properly with limits. Closes #41517 --- scripts/create_mysql_user.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/create_mysql_user.sh b/scripts/create_mysql_user.sh index 28f6cfb50ae..286b1325f1d 100644 --- a/scripts/create_mysql_user.sh +++ b/scripts/create_mysql_user.sh @@ -1,7 +1,7 @@ #!/bin/bash mysql --user=root --host=mysql < Date: Tue, 2 Jan 2018 15:49:39 -0500 Subject: Update script to work only when run in the gitlab directory. --- scripts/add-code-formatters | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'scripts') 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" -- cgit v1.2.1 From f6e5772dfc08d31b407b659ae85153eed67d76a6 Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Tue, 2 Jan 2018 15:57:45 -0500 Subject: Check for symlink instead of file before install. --- scripts/add-code-formatters | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/add-code-formatters b/scripts/add-code-formatters index e6fdac7a8e1..56bb8754d80 100755 --- a/scripts/add-code-formatters +++ b/scripts/add-code-formatters @@ -1,4 +1,6 @@ #!/bin/sh + +# Check if file exists with -f. Check if in in the gdk rook directory. if [ ! -f ../GDK_ROOT ]; then echo "Please run script from gitlab (e.g. gitlab-development-kit/gitlab) root directory." exit 1 @@ -6,7 +8,8 @@ fi PRECOMMIT=$(git rev-parse --git-dir)/hooks/pre-commit -if [ -f $PRECOMMIT ]; then +# Check if symlink exists with -L. Check if script was already installed. +if [ -L $PRECOMMIT ]; then echo "Pre-commit script already installed." exit 1 fi -- cgit v1.2.1 From 2abf63899d449c74090a4149f508a61e766d47ec Mon Sep 17 00:00:00 2001 From: Jacob Schatz Date: Tue, 2 Jan 2018 16:01:45 -0500 Subject: Add check if run from gitlab development kit root directory. --- scripts/pre-commit | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'scripts') diff --git a/scripts/pre-commit b/scripts/pre-commit index 380cc8d9022..48935e90a87 100644 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -1,4 +1,11 @@ #!/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 -- cgit v1.2.1