Skip to content

Commit

Permalink
forge--pullreq-range: New function
Browse files Browse the repository at this point in the history
Prefer the remote-tracking branch as that is more likely to be
up-to-date.  The `endpoints' argument is for when the range is
to be used to show a diff.  From git-diff(1):

> "diff" is about comparing two endpoints, not ranges, and the range
> notations ("<commit>..<commit>" and "<commit>...<commit>") do not
> mean a range as defined in the "SPECIFYING RANGES" section in
> gitrevisions(7).
  • Loading branch information
tarsius committed Jun 14, 2020
1 parent 6f299d2 commit 8beace1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lisp/forge-pullreq.el
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ yourself, in which case you probably should not reset either.
(let ((ref (format "refs/pullreqs/%s" (oref pullreq number))))
(and (magit-rev-verify ref) ref)))

(defun forge--pullreq-range (pullreq &optional endpoints)
(when-let ((head (forge--pullreq-ref pullreq)))
(concat (forge--get-remote) "/" (oref pullreq base-ref)
(if endpoints "..." "..")
head)))

(cl-defmethod forge-get-url ((pullreq forge-pullreq))
(forge--format pullreq 'pullreq-url-format))

Expand Down Expand Up @@ -245,11 +251,10 @@ Also see option `forge-topic-list-limit'."
(forge--topic-type-prefix repo 'pullreq)))))

(defun forge--insert-pullreq-commits (pullreq)
(when-let ((ref (forge--pullreq-ref pullreq)))
(when-let ((range (forge--pullreq-range pullreq)))
(magit-insert-section-body
(cl-letf (((symbol-function #'magit-cancel-section) (lambda ())))
(magit-insert-log (format "%s..%s" (oref pullreq base-ref) ref)
magit-buffer-log-args)
(magit-insert-log range magit-buffer-log-args)
(magit-make-margin-overlay nil t)))))

(cl-defmethod forge--insert-topic-contents :after ((pullreq forge-pullreq)
Expand Down

0 comments on commit 8beace1

Please sign in to comment.