Skip to content

Commit

Permalink
forge-thingatpt--{issue,pullreq}: Avoid determining repository
Browse files Browse the repository at this point in the history
Only do so if we know that is potentially useful.
  • Loading branch information
tarsius committed Dec 22, 2024
1 parent 5792f35 commit 683898d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 4 additions & 3 deletions lisp/forge-issue.el
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ an error."

(put 'forge-issue 'thing-at-point #'forge-thingatpt--issue)
(defun forge-thingatpt--issue ()
(and-let* ((repo (forge--repo-for-thingatpt)))
(and (thing-at-point-looking-at "#\\([0-9]+\\)\\_>")
(forge-get-issue repo (string-to-number (match-string 1))))))
(and-let* (((thing-at-point-looking-at "#\\([0-9]+\\)\\_>"))
(number (string-to-number (match-string 1)))
(repo (forge--repo-for-thingatpt)))
(forge-get-issue repo number)))

;;; Read

Expand Down
13 changes: 7 additions & 6 deletions lisp/forge-pullreq.el
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,13 @@ an error."

(put 'forge-pullreq 'thing-at-point #'forge-thingatpt--pullreq)
(defun forge-thingatpt--pullreq ()
(and-let* ((repo (forge--repo-for-thingatpt)))
(and (thing-at-point-looking-at
(if (forge-gitlab-repository--eieio-childp repo)
"[#!]\\([0-9]+\\)\\_>"
"#\\([0-9]+\\)\\_>"))
(forge-get-pullreq repo (string-to-number (match-string 1))))))
(and-let* (((thing-at-point-looking-at "\\([#!]\\)\\([0-9]+\\)\\_>"))
(prefix (match-string-no-properties 1))
(number (string-to-number (match-string-no-properties 2)))
(repo (forge--repo-for-thingatpt))
((or (equal prefix "#")
(forge-gitlab-repository--eieio-childp repo))))
(forge-get-pullreq repo number)))

;;; Read

Expand Down

0 comments on commit 683898d

Please sign in to comment.