From 7cc017ccc12921e38d0ace50400e096a4f6ddd2b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 23 Mar 2023 09:21:56 +1100 Subject: added buildbot build mode --- buildbot-build.el | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'buildbot-build.el') diff --git a/buildbot-build.el b/buildbot-build.el index ca1a8bc..a6c2b09 100644 --- a/buildbot-build.el +++ b/buildbot-build.el @@ -1,4 +1,43 @@ +(require 'buildbot-client) (define-derived-mode buildbot-build-mode special-mode "Buildbot build" "Buildbot view for a build") +(defvar-local buildbot-build-build-id nil) +(defvar-local buildbot-build-info nil) +(defun buildbot-build-buffer-name (buildid) + (concat "*buildbot build " (number-to-string buildid) "*")) + +(defun buildbot-build-load (buildid) + (let ((buffer-name (buildbot-build-buffer-name buildid))) + (with-current-buffer (get-buffer-create buffer-name) + (buildbot-build-mode) + (setq buildbot-build-build-id buildid) + (buildbot-build-update)) + (switch-to-buffer buffer-name))) + +(defun buildbot-build-update () + (unless (derived-mode-p 'buildbot-build-mode) + (error "Not in buildbot build mode")) + (let ((inhibit-read-only t)) + (erase-buffer) + (let ((steps (buildbot-get-steps-by-buildid buildbot-build-build-id))) + (insert (buildbot-build-format steps)) + (goto-char (point-min))))) + +(defun buildbot-build-open (buildid) + (interactive "sBuildi ID: ") + (buildbot-build-load (string-to-number buildid))) + +(defun buildbot-build-format (steps) + (string-join + (mapcar 'buildbot-build-format-step steps) + "\n")) + +(defun buildbot-build-format-step (step) + (propertize + (format "\n[%d %s %s]\n" + (alist-get 'number step) + (alist-get 'name step) + (alist-get 'state_string step)))) + (provide 'buildbot-build) -- cgit v1.2.3