termux_devenv/files/gitea-merge.sh

44 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
REPOAPIURL=https://git.bitmessage.org/api/v1/repos/Bitmessage/PyBitmessage
upstream="v0.6"
if [ -z "${1}" ]; then
echo "Please specify a credential string"
exit 1
fi
if [ -z "${2}" ]; then
echo "No PR# specified, here is a list:"
curl -s --request GET -u ${1} ${REPOAPIURL}/pulls \
| jq '.[] | select(.state == "open") | .number, .title' | paste - -
exit 1
fi
pr=$(curl -s --request GET -u ${1} ${REPOAPIURL}/pulls/${2})
branch=$(echo $pr | jq '.head | (.repo.ssh_url + " " + .label)' | tr -d '"')
title=$(echo $pr | jq '.title')
body=$(echo $pr | jq '.body')
echo "Merging PR ${2}"
git checkout -b gitea-${2} v0.6
git pull ${branch} || exit 1
git push --set-upstream origin gitea-${2}
if [ -z "${3}" ]; then
echo "No github credentials specified, stopping"
exit 1
fi
head=$(echo ${3} | cut -d: -f1):gitea-${2}
# echo "-d {\"title\":${title},\"body\":${body},\"head\":\"${head}\",\"base\":\"${upstream}\"}"
curl -u ${3} -X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/Bitmessage/PyBitmessage/pulls \
-d "{\"title\":${title},\"body\":${body},\"head\":\"${head}\",\"base\":\"${upstream}\"}"