x

Programs, configuration and documentation that don't fit anywhere else
Log | Files | Refs | README | LICENSE

commit 8bfd1f2450e99e16959cfdacaaaeefb8444aa6cf
parent a7c097f8bdb5834050510877297d9cfe4a36489f
Author: Oliver Lowe <o@olowe.co>
Date:   Thu,  3 Jul 2025 13:11:44 +1000

add bitbucket pull request create script

Diffstat:
Abin/bbpr | 46++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+), 0 deletions(-)

diff --git a/bin/bbpr b/bin/bbpr @@ -0,0 +1,46 @@ +#!/bin/sh + +# https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests + +confpath="$HOME/.config/atlassian/bitbucket.org" +if ! test -f $confpath +then + echo "load auth from $confpath: no such file" + exit 1 +fi +auth=`sed 1q $confpath` + +repo=`git remote get-url origin | awk -F : '{print $2}' | sed 's/\.git$//'` + +dest=main +if git branch --list master | grep master > /dev/null +then + dest=master +fi + +cover=`mktemp` +git log $dest.. | grep -v '^commit' > $cover + +if test -n $EDITOR +then + EDITOR=vi +fi +$EDITOR $cover + +title=`sed -n 1p $cover` + +description=`awk 'NR > 2 { print }' $cover` +rm $cover + +source=`git branch | grep '^\*' | awk '{print $2}'` +body=`jq -c <<EOF +{ + "title": "$title", + "description": "$description", + "source": { + "branch": { "name": "$source" } + } +} +EOF` + +curl -s -u "$auth" --json "$body" https://api.bitbucket.org/2.0/repositories/$repo/pullrequests | jq .links.html.href