From 6583303218c19c394eac34a792e4a326e1c19b0d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 15 Jul 2023 16:30:54 +1000 Subject: Adding support for more instances - Pass buildbot-host between buffers - Set buildbot-builders automatically - When the Changes API does not return builds, fetch the builds in a separate call This last change allows `buildbot-revision-open' to work with more instances, including python and buildbot. Also updated README with these changes, as well as ELPA installation info. --- buildbot-client.el | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'buildbot-client.el') diff --git a/buildbot-client.el b/buildbot-client.el index 0d4cf41..1aaf55f 100644 --- a/buildbot-client.el +++ b/buildbot-client.el @@ -30,7 +30,12 @@ (defvar-local buildbot-host nil "Buildbot instance host.") (defvar-local buildbot-builders nil "Buildbot builders. -Can be generated with `(buildbot-get-all-builders)'.") +Can be generated with `buildbot-get-all-builders'.") +(defgroup buildbot () "A Buildbot client." :group 'web) +(defcustom buildbot-default-host nil + "The default Buildbot instance host." + :group 'buildbot + :type 'string) (defun buildbot-api-change (attr) "Call the Changes API with ATTR." @@ -39,6 +44,13 @@ Can be generated with `(buildbot-get-all-builders)'.") "%s/api/v2/changes?%s" buildbot-host (buildbot-format-attr attr)))) +(defun buildbot-api-change-builds (change-id) + "Call the Changes API with CHANGE-ID to get all builds." + (buildbot-url-fetch-json + (format + "%s/api/v2/changes/%s/builds" + buildbot-host change-id))) + (defun buildbot-api-log (stepid) "Call the Logs API with STEPID." (buildbot-url-fetch-json @@ -120,8 +132,18 @@ Can be generated with `(buildbot-get-all-builders)'.") (defun buildbot-get-changes-by-revision (revision) "Get the changes from a REVISION." - (alist-get 'changes - (buildbot-api-change `((revision . ,revision))))) + (let ((changes + (alist-get 'changes + (buildbot-api-change `((revision . ,revision)))))) + (mapcar + (lambda (change) + (if (assq 'builds change) + change + (cons + (assq 'builds (buildbot-api-change-builds + (alist-get 'changeid change))) + change))) + changes))) (defun buildbot-get-build-by-buildid (buildid) "Get a build with BUILDID." -- cgit v1.2.3