~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH hg.sr.ht] Report buildsrht submit errors to the client

Details
Message ID
<dc3fb2d5a3e09c473968.1619153407@devahi>
DKIM signature
pass
Download raw message
Patch: +23 -7
# HG changeset patch
# User Ludovic Chabant <ludovic@chabant.com>
# Date 1619151830 0
#      Fri Apr 23 04:23:50 2021 +0000
# Node ID dc3fb2d5a3e09c473968d203df92ecf75b2a08af
# Parent  985f1740a51a91f11bcb70245b1e8d292a54476e
Report buildsrht submit errors to the client

diff --git a/hgsrht-hook-changegroup b/hgsrht-hook-changegroup
--- a/hgsrht-hook-changegroup
+++ b/hgsrht-hook-changegroup
@@ -20,8 +20,9 @@
    if repo_id is None:
        raise Exception("Server Error: repo info missing ID")
except Exception as ex:
    std.stderr.write(str(ex))
    sys.stderr.exit(1)
    sys.stderr.write(str(ex))
    sys.stderr.write("\n")
    sys.exit(1)

# If the repo was auto-created, print some warning.
if repo.get("visibility") == "autocreated":
@@ -41,10 +42,20 @@
headers.update(sign_payload(payload))
r = requests.post(f"{origin}/internal/hook-changegroup",
        data=payload, headers=headers)

try:
    response = r.json()
except:
    sys.stderr.write("Server Error: invalid response from internal hook\n")
    sys.exit(1)

if r.status_code == 200:
    response = r.json()
    status = response.get('status')
    msgs = response.get('messages')
    if status != 'skipped' and msgs:
        for msg in msgs:
            print(msg)
else:
    errormsg = response.get('why') or "unknown error"
    sys.stderr.write(f"Server Error: {errormsg}\n")
    sys.exit(1)
diff --git a/hgsrht/blueprints/internal.py b/hgsrht/blueprints/internal.py
--- a/hgsrht/blueprints/internal.py
+++ b/hgsrht/blueprints/internal.py
@@ -109,8 +109,13 @@
    db.session.commit()

    # Trigger buildsrht builds.
    res = trigger_changegroup_build(repo, node_last)
    if res is not None:
        return res.asdict(), 200
    try:
        res = trigger_changegroup_build(repo, node_last)
        if res is not None:
            return res.asdict(), 200

    return {}, 200
        return {}, 200
    except Exception as ex:
        return {
            "why": str(ex)
        }, 500
Details
Message ID
<CAVAFBKC3JRL.AQ1Y884DQ427@taiga>
In-Reply-To
<dc3fb2d5a3e09c473968.1619153407@devahi> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
LGTM. Ship it?
Details
Message ID
<661E81DD-0208-41FB-B7C3-58C6AF57F880@chabant.com>
In-Reply-To
<CAVAFBKC3JRL.AQ1Y884DQ427@taiga> (view parent)
DKIM signature
pass
Download raw message
Shipped!
Reply to thread Export thread (mbox)