Page MenuHomePhorge

No OneTemporary

Size
997 B
Referenced Files
None
Subscribers
None
diff --git a/lilybuild/lilybuild/forgejo.py b/lilybuild/lilybuild/forgejo.py
new file mode 100644
index 0000000..2d11b56
--- /dev/null
+++ b/lilybuild/lilybuild/forgejo.py
@@ -0,0 +1,22 @@
+
+from twisted.internet import defer
+from buildbot.www.hooks.github import GitHubEventHandler
+
+PARENT_FIRST = 'PARENT_FIRST'
+CHILD_FIRST = 'CHILD_FIRST'
+
+# Forgejo webhooks return the commits in child-first order
+# https://codeberg.org/forgejo/forgejo/issues/7737
+# This helper class intercepts the payload and reverse the
+# order of the commits.
+class ForgejoEventHandler(GitHubEventHandler):
+ def __init__(self, commits_order=CHILD_FIRST, **kwargs):
+ self.commits_order = commits_order
+ super().__init__(**kwargs)
+
+ @defer.inlineCallbacks
+ def _get_payload(self, request):
+ payload = yield super()._get_payload(request)
+ if 'commits' in payload and self.commits_order == CHILD_FIRST:
+ payload['commits'].reverse()
+ return payload

File Metadata

Mime Type
text/x-diff
Expires
Tue, Oct 13, 8:13 PM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1786887
Default Alt Text
(997 B)

Event Timeline