From 87e479e5f56c106c452bf0dc35ce3a328e69d4f6 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Thu, 10 Sep 2020 16:15:00 +0200 Subject: [PATCH] Checkout a PR thru PATCH-MENU (#1531) adding patch-menu item --- home.admin/99updateMenu.sh | 23 +++++++++++++++++++++-- home.admin/XXsyncScripts.sh | 14 +++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/home.admin/99updateMenu.sh b/home.admin/99updateMenu.sh index 31e8e5602..f364d4143 100755 --- a/home.admin/99updateMenu.sh +++ b/home.admin/99updateMenu.sh @@ -125,10 +125,11 @@ patch() # Patch Options OPTIONS=(PATCH "Patch/Sync RaspiBlitz with GitHub Repo" \ REPO "Change GitHub Repo to sync with" \ - BRANCH "Change GitHub Branch to sync with" + BRANCH "Change GitHub Branch to sync with" \ + PR "Checkout a PullRequest to test" ) - CHOICE=$(whiptail --clear --title "GitHub-User: ${activeGitHubUser} Branch: ${activeBranch}" --menu "" 10 55 3 "${OPTIONS[@]}" 2>&1 >/dev/tty) + CHOICE=$(whiptail --clear --title "GitHub-User: ${activeGitHubUser} Branch: ${activeBranch}" --menu "" 11 55 4 "${OPTIONS[@]}" 2>&1 >/dev/tty) clear case $CHOICE in @@ -185,6 +186,24 @@ patch() patch exit 1 ;; + PR) + clear + echo "..." + pullRequestID=$(whiptail --inputbox "\nPlease enter the NUMBER of the PullRequest on RaspiBlitz Repo '${activeGitHubUser}'?" 10 46 --title "Checkout PullRequest ID" 3>&1 1>&2 2>&3) + exitstatus=$? + if [ $exitstatus = 0 ]; then + pullRequestID=$(echo "${pullRequestID}" | cut -d " " -f1) + echo "--> " $pullRequestID + cd /home/admin/raspiblitz + git fetch origin pull/${pullRequestID}/head:${pullRequestID}pr + error="" + source <(sudo -u admin /home/admin/XXsyncScripts.sh ${pullRequestID}pr) + if [ ${#error} -gt 0 ]; then + whiptail --title "ERROR" --msgbox "${error}" 8 30 + fi + fi + exit 1 + ;; esac } diff --git a/home.admin/XXsyncScripts.sh b/home.admin/XXsyncScripts.sh index 74827b4ee..8260006f0 100755 --- a/home.admin/XXsyncScripts.sh +++ b/home.admin/XXsyncScripts.sh @@ -83,17 +83,17 @@ if [ ${#wantedBranch} -gt 0 ]; then echo "# OK" else - echo "# checking branch exists .." - branchExists=$(curl -s https://api.github.com/repos/${activeGitHubUser}/raspiblitz/branches/${wantedBranch} | jq -r '.name' | grep -c ${wantedBranch}) - if [ ${branchExists} -eq 0 ]; then - echo "error='branch not found'" - exit 1 - fi - echo "# checking if branch is locally available" localBranch=$(git branch | grep -c "${wantedBranch}") if [ ${localBranch} -eq 0 ]; then + echo "# checking branch exists .." + branchExists=$(curl -s https://api.github.com/repos/${activeGitHubUser}/raspiblitz/branches/${wantedBranch} | jq -r '.name' | grep -c ${wantedBranch}) + if [ ${branchExists} -eq 0 ]; then + echo "error='branch not found'" + exit 1 + fi echo "# checkout/changing branch .." + git fetch git checkout -b ${wantedBranch} origin/${wantedBranch} else echo "# changing branch .."