From 70224f8e71adb001b20e2c7a3cf5020c050bf464 Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Wed, 21 Apr 2021 10:39:25 +0200 Subject: [PATCH] Add ghpr script --- script/ghpr | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 script/ghpr diff --git a/script/ghpr b/script/ghpr new file mode 100755 index 0000000..b919912 --- /dev/null +++ b/script/ghpr @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Open or create a GitHub PR in the browser + +export GH_NO_UPDATE_NOTIFIER=1 + +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 + echo $output + exit $exitcode +fi