2021-04-21 08:39:25 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Open or create a GitHub PR in the browser
|
|
|
|
|
|
|
|
export GH_NO_UPDATE_NOTIFIER=1
|
2021-10-19 14:36:17 +00:00
|
|
|
unset BROWSER
|
2021-04-21 08:39:25 +00:00
|
|
|
|
2021-05-17 09:28:27 +00:00
|
|
|
currentbranch="$(git bn)"
|
|
|
|
if [ "$currentbranch" = "staging" ] || [ "$currentbranch" = "master" ]; then
|
|
|
|
echo "Are you sure? Currently on branch '$currentbranch'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-04-21 08:39:25 +00:00
|
|
|
output=$(gh pr view -w 2>&1)
|
|
|
|
exitcode=$?
|
|
|
|
|
|
|
|
if [ $exitcode -eq 0 ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if echo "$output" | grep -q "no pull requests found"; then
|
|
|
|
echo "Opening new PR..."
|
|
|
|
gh pr create -w
|
|
|
|
else
|
2023-10-07 08:43:32 +00:00
|
|
|
echo "$output"
|
2021-04-21 08:39:25 +00:00
|
|
|
exit $exitcode
|
|
|
|
fi
|