[gnome-shell] ci: Make run-eslint more convenient for local use



commit d12cd12e1b8428c669c013036f6617c81f7477b7
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Sep 14 17:09:04 2019 +0200

    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 edcdfc1fd8..103ba93611 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
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]