aboutsummaryrefslogtreecommitdiff
path: root/buildbot-build.el
blob: a6c2b0961c0281324a12cf4ee1c7c40b50e0d0f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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)