ci: Make run-eslint more convenient for local use

The script can be helpful outside of CI, in particular for gradually
transitioning to the new style.

Reverting commit f00201fa6c it is already possible to do something
like

 $ CI_MERGE_REQUEST_PROJECT_URL=https://gitlab.gnome.org/GNOME/gnome-shell \
   CI_MERGE_REQUEST_TARGET_BRANCH_NAME=master CI_COMMIT_SHA=HEAD \
   .gitlab-ci/run-eslint.sh

but that is hardly convenient.

Instead, allow passing the required parameters on the command line:

 $ .gitlab-ci/run-eslint.sh origin master

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/730
This commit is contained in:
Florian Müllner 2019-09-14 17:09:04 +02:00 committed by Florian Müllner
parent caa50dc1a3
commit d12cd12e1b

View File

@ -76,10 +76,13 @@ create_common() {
# non-legacy style just yet ... # non-legacy style just yet ...
unset CI_MERGE_REQUEST_TARGET_BRANCH_NAME unset CI_MERGE_REQUEST_TARGET_BRANCH_NAME
if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then REMOTE=${1:-$CI_MERGE_REQUEST_PROJECT_URL.git}
git fetch $CI_MERGE_REQUEST_PROJECT_URL.git $CI_MERGE_REQUEST_TARGET_BRANCH_NAME BRANCH_NAME=${2:-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
if [ "$BRANCH_NAME" ]; then
git fetch $REMOTE $BRANCH_NAME
branch_point=$(git merge-base HEAD FETCH_HEAD) branch_point=$(git merge-base HEAD FETCH_HEAD)
commit_range=$branch_point...$CI_COMMIT_SHA commit_range=$branch_point...HEAD
list_commit_range_additions $commit_range > $LINE_CHANGES list_commit_range_additions $commit_range > $LINE_CHANGES
@ -102,7 +105,7 @@ if ! is_empty $OUTPUT_FINAL; then
fi fi
# Just show the report and succeed when not testing a MR # Just show the report and succeed when not testing a MR
if [ -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then if [ -z "$BRANCH_NAME" ]; then
exit 0 exit 0
fi fi