~niklaseklund/egerrit

97cf692a28982b273759e270e0abe63c1a80c8fe — Niklas Eklund a month ago 86b1079
Address error in open job
1 files changed, 28 insertions(+), 28 deletions(-)

M egerrit-job.el
M egerrit-job.el => egerrit-job.el +28 -28
@@ 152,34 152,34 @@ to show and which functions to call to get the right data."
  "Open one of CHANGE's jobs.

Optionally provide a REVISION to select job from."
  (interactive
   (list
    (egerrit-get-detailed-change
     (tabulated-list-get-id))))
  (if (and (eq egerrit--mode 'reviewer)
           (not (egerrit--clean-git-repository change)))
      (message "The git repository can't be dirty when engaging in a review")
    (when-let* ((egerrit--current-change change)
                (project-root (egerrit-get-project-root egerrit--current-change))
                (default-directory project-root)
                (revision
                 (or revision
                     (if current-prefix-arg
                         (egerrit-select-revision egerrit--current-change)
                       (seq-first (seq-reverse (egerrit--change-revisions egerrit--current-change))))))
                (mode egerrit--mode)
                (buffer (egerrit-get-buffer "egerrit-job"))
                (jobs (egerrit--revision-jobs revision))
                (job (egerrit-select-job jobs)))
      (with-current-buffer buffer
        (egerrit--open-job job buffer)
        (egerrit--switch-branch change revision)
        (setq egerrit--current-jobs jobs)
        (setq egerrit--current-change change)
        (setq egerrit--current-revision revision)
        (setq egerrit--current-dashboard (egerrit-get-buffer "egerrit-dashboard"))
        (setq egerrit--mode mode)
        (setq-local default-directory project-root)))))
  (interactive)
  (let ((change (or change
                    (egerrit-get-detailed-change
                     (tabulated-list-get-id))))
        (mode egerrit--mode))
    (if (and (eq egerrit--mode 'reviewer)
             (not (egerrit--clean-git-repository change)))
        (message "The git repository can't be dirty when engaging in a review")
      (when-let* ((egerrit--current-change change)
                  (project-root (egerrit-get-project-root egerrit--current-change))
                  (default-directory project-root)
                  (revision
                   (or revision
                       (if current-prefix-arg
                           (egerrit-select-revision egerrit--current-change)
                         (seq-first (seq-reverse (egerrit--change-revisions egerrit--current-change))))))
                  (buffer (egerrit-get-buffer "egerrit-job"))
                  (jobs (egerrit--revision-jobs revision))
                  (job (egerrit-select-job jobs)))
        (with-current-buffer buffer
          (egerrit--open-job job buffer)
          (egerrit--switch-branch change revision)
          (setq egerrit--current-jobs jobs)
          (setq egerrit--current-change change)
          (setq egerrit--current-revision revision)
          (setq egerrit--current-dashboard (egerrit-get-buffer "egerrit-dashboard"))
          (setq egerrit--mode mode)
          (setq-local default-directory project-root))))))

;;;; Support functions