Checkout a PR thru PATCH-MENU (#1531)

adding patch-menu item
This commit is contained in:
Christian Rotzoll 2020-09-10 16:15:00 +02:00 committed by GitHub
parent 71d20d5bc3
commit 87e479e5f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 9 deletions

View file

@ -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
}

View file

@ -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 .."