From d12cd12e1b8428c669c013036f6617c81f7477b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 14 Sep 2019 17:09:04 +0200 Subject: [PATCH] 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 f00201fa6ca 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 --- .gitlab-ci/run-eslint.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci/run-eslint.sh b/.gitlab-ci/run-eslint.sh index edcdfc1fd..103ba9361 100755 --- a/.gitlab-ci/run-eslint.sh +++ b/.gitlab-ci/run-eslint.sh @@ -76,10 +76,13 @@ create_common() { # non-legacy style just yet ... unset CI_MERGE_REQUEST_TARGET_BRANCH_NAME -if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then - git fetch $CI_MERGE_REQUEST_PROJECT_URL.git $CI_MERGE_REQUEST_TARGET_BRANCH_NAME +REMOTE=${1:-$CI_MERGE_REQUEST_PROJECT_URL.git} +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) - commit_range=$branch_point...$CI_COMMIT_SHA + commit_range=$branch_point...HEAD list_commit_range_additions $commit_range > $LINE_CHANGES @@ -102,7 +105,7 @@ if ! is_empty $OUTPUT_FINAL; then fi # 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 fi