Add -a option to import all GH PRs regardless of CI status

Change-Id: I9754d0cb3714da886389bcc2fdbbe9b69d4b5ae4
diff --git a/bin/import_github_pull_requests b/bin/import_github_pull_requests
index d8b2235..57cb9a9 100755
--- a/bin/import_github_pull_requests
+++ b/bin/import_github_pull_requests
@@ -3,8 +3,9 @@
 Script to import pull requests from github to your local repository and to give you
 some suggestion how to send them to your gerrit server.
 
-Usage: $0 [-h] [-v] [-f]
+Usage: $0 [-h] [-v] [-f] [-a]
         -f   import PRs with **failed** CI tests
+        -a   import **all** PRs regardless of CI status
 
 Example use:
 cd ~/KorAP/Kustvakt
@@ -25,13 +26,18 @@
 EOF
 fi
 GET_CI_STATUS_SUCCESS="true"
+GET_ALL_PRS="false"
 REVIEW_SUGGESTION="+1"
-while getopts ":vfh" opt; do
+while getopts ":vfah" opt; do
   case ${opt} in
   f )
     GET_CI_STATUS_SUCCESS="false"
     REVIEW_SUGGESTION="-2"
     ;;
+  a )
+    GET_ALL_PRS="true"
+    REVIEW_SUGGESTION="+0"
+    ;;
   v )
     set -x
     VERBOSE=1
@@ -75,14 +81,14 @@
     fi
   fi
 done <<<$(
-  if [ -e .github/workflows ]; then
-    curl $GITHUB_KORAP_REPO_AUTH -s "https://api.github.com/repos/${ORG}/${REPO}/actions/workflows/${WORKFLOW}/runs?event=pull_request" |
-    jq '.workflow_runs[] | select(.head_commit.message!="trigger github actions") | {success: (.conclusion=="success"), pr:.pull_requests[].number, sha:.pull_requests[].head.sha, message:.head_commit.message} | join(",")' |
-    sed 's/["]//g' | sed 's/\\n\\n.*//g'
-  else
+  if [ "$GET_ALL_PRS" == "true" ] || [ ! -e .github/workflows ]; then
     curl $GITHUB_KORAP_REPO_AUTH -s "https://api.github.com/repos/${ORG}/${REPO}/pulls?state=open" |
      jq '.[] | { success: "true", pr:.number, sha:.head.sha, message:.title} | join(",")' |
-      sed 's/["]//g' | sed 's/\\n\\n.*//g'
+      sed 's/[\"]//g' | sed 's/\\\\n\\\\n.*//g'
+  else
+    curl $GITHUB_KORAP_REPO_AUTH -s "https://api.github.com/repos/${ORG}/${REPO}/actions/workflows/${WORKFLOW}/runs?event=pull_request" |
+    jq '.workflow_runs[] | select(.head_commit.message!="trigger github actions") | {success: (.conclusion=="success"), pr:.pull_requests[].number, sha:.pull_requests[].head.sha, message:.head_commit.message} | join(",")' |
+    sed 's/[\"]//g' | sed 's/\\\\n\\\\n.*//g'
   fi
 )
 if [ -e ${COMMIT_MSG_HOOK_BAK} ]; then