2022-04-22 23:45:41 +00:00
|
|
|
#!/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 \
|
2022-05-18 23:19:12 +00:00
|
|
|
| jq '.[] | select(.state == "open") | .number, .title' | paste - -
|
2022-04-22 23:45:41 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
pr=$(curl -s --request GET -u ${1} ${REPOAPIURL}/pulls/${2})
|
|
|
|
|
2022-05-18 23:19:12 +00:00
|
|
|
branch=$(echo $pr | jq '.head | (.repo.ssh_url + " " + .label)' | tr -d '"')
|
2022-04-22 23:45:41 +00:00
|
|
|
title=$(echo $pr | jq '.title')
|
|
|
|
body=$(echo $pr | jq '.body')
|
|
|
|
|
|
|
|
|
|
|
|
echo "Merging PR ${2}"
|
|
|
|
|
2022-05-24 23:51:10 +00:00
|
|
|
git branch -d gitea-${2}
|
2022-04-22 23:45:41 +00:00
|
|
|
git checkout -b gitea-${2} v0.6
|
2022-05-18 23:19:12 +00:00
|
|
|
git pull ${branch} || exit 1
|
2022-04-22 23:45:41 +00:00
|
|
|
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}
|
|
|
|
|
2022-05-24 23:51:10 +00:00
|
|
|
REPOAPIURL=https://api.github.com/repos/Bitmessage/PyBitmessage
|
2022-04-22 23:45:41 +00:00
|
|
|
|
2022-05-24 23:51:10 +00:00
|
|
|
pr=$(curl -s -u ${3} -X POST \
|
|
|
|
-H "Accept: application/vnd.github.v3+json" ${REPOAPIURL}/pulls \
|
|
|
|
-d "{\"title\":${title},\"body\":${body},\"head\":\"${head}\",\"base\":\"${upstream}\"}")
|
|
|
|
|
|
|
|
# commit=$(echo $pr | jq '.head.sha')
|
|
|
|
# url=$(echo $pr | jq '.url')
|
|
|
|
|
|
|
|
# checks=$(
|
|
|
|
# curl -s --request GET \
|
|
|
|
# -H "Accept: application/vnd.github.v3+json" \
|
|
|
|
# ${REPOAPIURL}/commits/${commit}/check-runs)
|
|
|
|
|
|
|
|
# sleep 10
|
|
|
|
|
|
|
|
# echo $checks | jq '(.check_runs | map(select(.conclusion == "success")) | length) == .total_count'
|
|
|
|
|
|
|
|
# curl -s -u ${3} -X POST \
|
|
|
|
# -H "Accept: application/vnd.github.v3+json" $url -d '{"event":"APPROVE"}'
|