summaryrefslogtreecommitdiff
path: root/tools/patchbot/bin/git-submit
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-12-29 23:04:50 +0000
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2026-04-04 01:37:54 +0100
commitcf1a3fd1e4267ec522c10da087262daddc782b20 (patch)
treed11b34eafa4301fe08bdf03027cf6ef9e580f189 /tools/patchbot/bin/git-submit
parent2088b61f3d6053d3879dcfcbe91c00157d050e16 (diff)
downloadsst-cf1a3fd1e4267ec522c10da087262daddc782b20.tar.gz
sst-cf1a3fd1e4267ec522c10da087262daddc782b20.zip
Add PatchBot stuff
These are a little different than the ones we were using privately before and will require some one-off hopefully straightforward copy-pasting for existing developers. But hopefully this'll remove some friction from using the thing across the board. I'd still like to investigate smoother auth methods in the future. The SSH key idea seems like a good one, but there's some annoying obstacles there. There's also the idea of having the Discord bot send people tokens. For now, it's still just manual, which is probably good enough for quite a long time, to be honest. This also includes the Sorse Tecknoledgy Committy Discord link, because I've kind of not done well to advertise the existence of that thing. It has always been technically open the public, except many people probably don't know it's there.
Diffstat (limited to 'tools/patchbot/bin/git-submit')
-rwxr-xr-xtools/patchbot/bin/git-submit64
1 files changed, 64 insertions, 0 deletions
diff --git a/tools/patchbot/bin/git-submit b/tools/patchbot/bin/git-submit
new file mode 100755
index 0000000..70c2efc
--- /dev/null
+++ b/tools/patchbot/bin/git-submit
@@ -0,0 +1,64 @@
+#!/bin/sh
+# This file is dedicated to the public domain.
+
+set -e # windows git doesn't seem to like flags in the shebang!?
+
+usage() {
+ printf 'usage: git submit [-p projectid] description [range]\n' >&2
+ exit 1
+}
+
+while getopts ":p:" arg; do
+ case "$arg" in
+ p) projectid="$OPTARG" ;;
+ *) usage ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+if [ $# -lt 1 -o $# -gt 2 ]; then usage; fi
+description="$1"
+
+. "`dirname "$0"`/../lib/patchbot-setup.sh"
+
+range="${2:-"$remote_branch"}"
+
+git format-patch --histogram --stdout "$range" > "$gitdir/PatchBot.req.tmp"
+
+rmtmp() {
+ rm -f "$gitdir/PatchBot.req.tmp" "$gitdir/PatchBot.resp.tmp"
+}
+
+doreq() {
+ "$curl" -sLXPOST -H"Authorization: Bearer $token" \
+ -H"Content-Type: application/mbox" \
+ -H"User-Agent: patchbot-client v3" \
+ --data-binary @"$gitdir/PatchBot.req.tmp" - \
+ --url-query "projectid=$projectid" \
+ --url-query "description=$description" \
+ -o "$gitdir/PatchBot.resp.tmp" \
+ "$server/submit" >&2
+}
+dumpresponse() {
+ printf "Server returned HTTP status $httpcode.\nResponse:\n" >&2
+ < "$gitdir/PatchBot.resp.tmp" sed 's/^/| /' >&2 # indent it!
+}
+
+# server doesn't allow anonymous submits. make sure we have a token first.
+if [ -z "$token" ]; then
+ printf "error: submitting to PatchBot requires an auth token\n">&2
+ setupauth;
+fi
+httpcode="`doreq`"
+if [ "$httpcode" != 200 ]; then
+ dumpresponse
+ rmtmp
+ exit 2
+else
+ # just cat the response directly, it should be a brief message intended for
+ # direct display, containing the patchset number.
+ cat "$gitdir/PatchBot.resp.tmp"
+ rmtmp
+fi
+
+# vi: sw=4 ts=4 noet tw=80 cc=80