From 85226d08b024731765102174b1f4197e1a35f7a1 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 2 Sep 2024 01:43:30 +0200 Subject: fix[po] don't use external script --- po | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'po') diff --git a/po b/po index a2ac3a8..75faecb 100755 --- a/po +++ b/po @@ -1,11 +1,26 @@ #!/bin/sh -set -eux +set -eu if [ ! -d .osc ] && [ ! -d .git ] ; then echo 'This program must be run from an project directory.' exit 42 fi +which_pr() { + TOKEN=$(pass show dev/github.com|awk '/^token:/ {print $2}') + ORIG_USER=$(git remote get-url origin 2>/dev/null|awk -F/ '{print $4}') + REPO=$(git remote get-url origin 2>/dev/null|awk -F'[/.]' '{print $6}') + USER=$(git remote get-url github 2>/dev/null|awk -F/ '{print $4}') + BRANCH=$(git rev-parse --abbrev-ref HEAD) + + curl -s -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/$ORIG_USER/$REPO/pulls?head=mcepl:$BRANCH" \ + | jq -r .[].html_url 2>/dev/null +} + o_url="" if [ -f .osc/_packages ] ; then apiurl=$(cat .osc/_apiurl) @@ -19,7 +34,7 @@ elif [ -f .osc/_package ] ; then fi if [ -z "$o_url" ] ; then - pr_url="$(gh-which-pr)" || true + pr_url="$(which_pr)" || true if [ -n "$pr_url" ] ; then o_url="$pr_url" elif [ -d .git ] ; then -- cgit