diff options
author | Yuchen Pei <hi@ypei.me> | 2023-03-24 00:08:42 +1100 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2023-03-24 00:08:42 +1100 |
commit | 94172a6c655ea4aefe2960aa5db9fec77130e87d (patch) | |
tree | 59b27daaf1f553d5e282799941af27c01aeadfaa /buildbot-step.el | |
parent | 7cc017ccc12921e38d0ace50400e096a4f6ddd2b (diff) |
Adding step mode. Also refactoring
Diffstat (limited to 'buildbot-step.el')
-rw-r--r-- | buildbot-step.el | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/buildbot-step.el b/buildbot-step.el new file mode 100644 index 0000000..1058410 --- /dev/null +++ b/buildbot-step.el @@ -0,0 +1,54 @@ +;; -*- lexical-binding: t; -*- +(require 'buildbot-client) +(require 'buildbot-view) + +(define-derived-mode buildbot-step-mode buildbot-view-mode "Buildbot step" + "Buildbot view for a step") + +(defvar-local buildbot-step-revision-info nil) +(defvar-local buildbot-step-build nil) +(defvar-local buildbot-step-step nil) +(defun buildbot-step-buffer-name (stepid) + (concat "*buildbot step " (number-to-string stepid) "*")) + +(defun buildbot-step-load (revision-info build step) + (let ((buffer-name (buildbot-step-buffer-name (alist-get 'stepid step)))) + (with-current-buffer (get-buffer-create buffer-name) + (buildbot-step-mode) + (setq buildbot-step-revision-info revision-info + buildbot-step-build build + buildbot-step-step step) + (buildbot-step-update)) + (switch-to-buffer buffer-name))) + +(defun buildbot-step-update () + (unless (derived-mode-p 'buildbot-step-mode) + (error "Not in buildbot step mode")) + (let ((inhibit-read-only t)) + (erase-buffer) + (let ((logs (buildbot-get-logs-by-stepid + (alist-get 'stepid buildbot-step-step)))) + (insert (buildbot-step-format + buildbot-step-revision-info + buildbot-step-build + buildbot-step-step + logs)) + (goto-char (point-min))))) + +(defun buildbot-step-reload () + (interactive) + (buildbot-step-update)) +(define-key buildbot-step-mode-map "g" 'buildbot-step-reload) + +(defun buildbot-step-format (revision-info build step logs) + (concat + (buildbot-view-format-revision-info revision-info) + "\n" + (buildbot-view-format-build build) + "\n" + (buildbot-view-format-step step) + (string-join + (mapcar 'buildbot-view-format-log logs) + "\n"))) + +(provide 'buildbot-step) |