Start writing the script for merging a gitea PR

This commit is contained in:
Lee Miller 2022-04-23 02:45:41 +03:00
parent 3c4061b37e
commit 3127fa2e4c
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
1 changed files with 43 additions and 0 deletions

43
files/gitea-merge.sh Executable file
View File

@ -0,0 +1,43 @@
#!/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 '.[] | .number, .title' | paste - -
exit 1
fi
pr=$(curl -s --request GET -u ${1} ${REPOAPIURL}/pulls/${2})
branch=$(echo $pr | jq '.head | (.repo.clone_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}
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}\"}"