aboutsummaryrefslogtreecommitdiffstats
path: root/po
diff options
context:
space:
mode:
Diffstat (limited to 'po')
-rwxr-xr-xpo41
1 files changed, 24 insertions, 17 deletions
diff --git a/po b/po
index 1ae36fb..a2ac3a8 100755
--- a/po
+++ b/po
@@ -1,4 +1,6 @@
#!/bin/sh
+set -eux
+
if [ ! -d .osc ] && [ ! -d .git ] ; then
echo 'This program must be run from an project directory.'
exit 42
@@ -14,22 +16,27 @@ elif [ -f .osc/_package ] ; then
project=$(cat .osc/_project)
package=$(cat .osc/_package)
o_url="${apiurl}/package/show/${project}/${package}"
-elif [ -d .git ] ; then
- if git remote show gitlab >/dev/null 2>&1 ; then
- o_url="$(git remote get-url gitlab)"
- elif git remote show github >/dev/null 2>&1 ; then
- o_url="$(git remote get-url github)"
- elif git remote show sourcehut >/dev/null 2>&1 ; then
- o_url="$(git remote get-url sourcehut)"
- elif git remote show myrepo >/dev/null 2>&1 ; then
- o_url="$(git remote get-url myrepo)"
- elif git remote show origin >/dev/null 2>&1 ; then
- o_url="$(git remote get-url origin)"
- else
- exit 0
- fi
-else
- exit 0
fi
-xdg-open "$o_url" >/dev/null 2>&1
+if [ -z "$o_url" ] ; then
+ pr_url="$(gh-which-pr)" || true
+ if [ -n "$pr_url" ] ; then
+ o_url="$pr_url"
+ elif [ -d .git ] ; then
+ if git remote show gitlab >/dev/null 2>&1 ; then
+ o_url="$(git remote get-url gitlab)"
+ elif git remote show github >/dev/null 2>&1 ; then
+ o_url="$(git remote get-url github)"
+ elif git remote show sourcehut >/dev/null 2>&1 ; then
+ o_url="$(git remote get-url sourcehut)"
+ elif git remote show myrepo >/dev/null 2>&1 ; then
+ o_url="$(git remote get-url myrepo)"
+ elif git remote show origin >/dev/null 2>&1 ; then
+ o_url="$(git remote get-url origin)"
+ else
+ exit 0
+ fi
+ fi
+fi
+
+[ -z "$o_url" ] || xdg-open "$o_url" >/dev/null 2>&1