aboutsummaryrefslogtreecommitdiff
path: root/buildbot-build.el
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2023-03-24 00:08:42 +1100
committerYuchen Pei <hi@ypei.me>2023-03-24 00:08:42 +1100
commit94172a6c655ea4aefe2960aa5db9fec77130e87d (patch)
tree59b27daaf1f553d5e282799941af27c01aeadfaa /buildbot-build.el
parent7cc017ccc12921e38d0ace50400e096a4f6ddd2b (diff)
Adding step mode. Also refactoring
Diffstat (limited to 'buildbot-build.el')
-rw-r--r--buildbot-build.el64
1 files changed, 41 insertions, 23 deletions
diff --git a/buildbot-build.el b/buildbot-build.el
index a6c2b09..9e3d913 100644
--- a/buildbot-build.el
+++ b/buildbot-build.el
@@ -1,17 +1,21 @@
+;; -*- lexical-binding: t; -*-
(require 'buildbot-client)
-(define-derived-mode buildbot-build-mode special-mode "Buildbot build"
+(require 'buildbot-view)
+
+(define-derived-mode buildbot-build-mode buildbot-view-mode "Buildbot build"
"Buildbot view for a build")
-(defvar-local buildbot-build-build-id nil)
-(defvar-local buildbot-build-info nil)
+(defvar-local buildbot-build-build nil)
+(defvar-local buildbot-build-revision-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)))
+(defun buildbot-build-load (build revision-info)
+ (let ((buffer-name (buildbot-build-buffer-name (alist-get 'id build))))
(with-current-buffer (get-buffer-create buffer-name)
(buildbot-build-mode)
- (setq buildbot-build-build-id buildid)
+ (setq buildbot-build-build build
+ buildbot-build-revision-info revision-info)
(buildbot-build-update))
(switch-to-buffer buffer-name)))
@@ -20,24 +24,38 @@
(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))
+ (let ((steps (buildbot-get-steps-by-buildid
+ (alist-get 'id buildbot-build-build))))
+ (insert (buildbot-build-format
+ buildbot-build-revision-info
+ buildbot-build-build
+ 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))))
+(defun buildbot-build-reload ()
+ (interactive)
+ (buildbot-build-update))
+(define-key buildbot-build-mode-map "g" 'buildbot-build-reload)
+
+(defun buildbot-build-format (revision-info build steps)
+ (concat
+ (buildbot-view-format-revision-info revision-info)
+ "\n"
+ (buildbot-view-format-build build)
+ "\n"
+ (string-join
+ (mapcar 'buildbot-view-format-step steps)
+ "\n")))
+
+(defun buildbot-build-open-step ()
+ (interactive)
+ (let ((step (get-text-property (point) 'step)))
+ (unless step
+ (error "Not at a step"))
+ (buildbot-step-load buildbot-build-revision-info
+ buildbot-build-build
+ step)))
+(define-key buildbot-build-mode-map (kbd "<return>")
+ 'buildbot-build-open-step)
(provide 'buildbot-build)