| OLD | NEW |
| 1 ; To use this, | 1 ; To use this, |
| 2 ; 1) Add to init.el: | 2 ; 1) Add to init.el: |
| 3 ; (setq-default chrome-root "/path/to/chrome/src/") | 3 ; (setq-default chrome-root "/path/to/chrome/src/") |
| 4 ; (add-to-list 'load-path (concat chrome-root "tools/emacs")) | 4 ; (add-to-list 'load-path (concat chrome-root "tools/emacs")) |
| 5 ; (require 'trybot) | 5 ; (require 'trybot) |
| 6 ; 2) Run on trybot output: | 6 ; 2) Run on trybot output: |
| 7 ; M-x trybot | 7 ; M-x trybot |
| 8 ; | 8 ; |
| 9 ; To hack on this, | 9 ; To hack on this, |
| 10 ; M-x eval-buffer | 10 ; M-x eval-buffer |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 (get-buffer-create buffer-name))) | 96 (get-buffer-create buffer-name))) |
| 97 | 97 |
| 98 (defun trybot-fetch (type-hint url) | 98 (defun trybot-fetch (type-hint url) |
| 99 "Fetch a URL and postprocess it as trybot output." | 99 "Fetch a URL and postprocess it as trybot output." |
| 100 | 100 |
| 101 (let ((on-fetch-completion | 101 (let ((on-fetch-completion |
| 102 (lambda (process state) | 102 (lambda (process state) |
| 103 (switch-to-buffer (process-buffer process)) | 103 (switch-to-buffer (process-buffer process)) |
| 104 (when (equal state "finished\n") | 104 (when (equal state "finished\n") |
| 105 (trybot-fixup (process-get process 'type-hint))))) | 105 (trybot-fixup (process-get process 'type-hint))))) |
| 106 (command (concat "curl -s " url | 106 (command (concat "curl -s " (shell-quote-argument url) |
| 107 (when (eq type-hint 'mac) | 107 ; Pipe it through the output shortener. |
| 108 ; Pipe it through the output shortener. | 108 (cond |
| 109 ((eq type-hint 'win) |
| 109 (concat " | " (get-chrome-root) | 110 (concat " | " (get-chrome-root) |
| 110 "build/sanitize-mac-build-log.sh"))))) | 111 "build/sanitize-win-build-log.sh")) |
| 112 ((eq type-hint 'mac) |
| 113 (concat " | " (get-chrome-root) |
| 114 "build/sanitize-mac-build-log.sh")))))) |
| 111 | 115 |
| 112 ; Start up the subprocess. | 116 ; Start up the subprocess. |
| 113 (let* ((coding-system-for-read 'utf-8-dos) | 117 (let* ((coding-system-for-read 'utf-8-dos) |
| 114 (buffer (trybot-get-new-buffer)) | 118 (buffer (trybot-get-new-buffer)) |
| 115 (process (start-process-shell-command "curl" buffer command))) | 119 (process (start-process-shell-command "curl" buffer command))) |
| 116 ; Attach the type hint to the process so we can get it back when | 120 ; Attach the type hint to the process so we can get it back when |
| 117 ; the process completes. | 121 ; the process completes. |
| 118 (process-put process 'type-hint type-hint) | 122 (process-put process 'type-hint type-hint) |
| 119 (set-process-query-on-exit-flag process nil) | 123 (set-process-query-on-exit-flag process nil) |
| 120 (set-process-sentinel process on-fetch-completion)))) | 124 (set-process-sentinel process on-fetch-completion)))) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 147 (when (= (length url) 0) | 151 (when (= (length url) 0) |
| 148 (with-temp-buffer | 152 (with-temp-buffer |
| 149 (clipboard-yank) | 153 (clipboard-yank) |
| 150 (setq url (buffer-string)))) | 154 (setq url (buffer-string)))) |
| 151 | 155 |
| 152 ;; Append /text to the URL to get plain text output in the common | 156 ;; Append /text to the URL to get plain text output in the common |
| 153 ;; case of getting a URL to the HTML build log. | 157 ;; case of getting a URL to the HTML build log. |
| 154 (when (equal "stdio" (car (last (split-string url "/")))) | 158 (when (equal "stdio" (car (last (split-string url "/")))) |
| 155 (setq url (concat url "/text"))) | 159 (setq url (concat url "/text"))) |
| 156 | 160 |
| 157 (let ((type-hint (cond ((string-match "/win/" url) 'win) | 161 (let ((type-hint (cond ((string-match "/[Ww]in" url) 'win) |
| 158 ((string-match "/mac/" url) 'mac) | 162 ((string-match "/mac/" url) 'mac) |
| 159 ; Match /linux, /linux_view, etc. | 163 ; Match /linux, /linux_view, etc. |
| 160 ((string-match "/linux" url) 'linux) | 164 ((string-match "/linux" url) 'linux) |
| 161 (t 'unknown)))) | 165 (t 'unknown)))) |
| 162 (trybot-fetch type-hint url))) | 166 (trybot-fetch type-hint url))) |
| 163 | 167 |
| 164 (provide 'trybot) | 168 (provide 'trybot) |
| OLD | NEW |