summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2019-10-10 18:16:28 -0400
committerKyle Meyer <kyle@kyleam.com>2019-10-10 18:16:28 -0400
commitd06363b393e5b1519b15f4123dd67c0f928259bf (patch)
treea5e5509101c70d476a9cdbfad90c2b369e5cbbc6 /lisp
parentaa1f1429003ff8ac8a408b057864ba83f7ba6428 (diff)
downloademacs.d-d06363b393e5b1519b15f4123dd67c0f928259bf.tar.gz
km/magit-github-url: Try origin URL if bug-reference URL is unset
Diffstat (limited to 'lisp')
-rw-r--r--lisp/km-magit.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/km-magit.el b/lisp/km-magit.el
index 2967c86..d83e9e1 100644
--- a/lisp/km-magit.el
+++ b/lisp/km-magit.el
@@ -810,7 +810,7 @@ function."
;;; GitHub links
-(defun km/magit-github-url ()
+(defun km/magit-github-url-from-bugref ()
;; `bug-reference-url-format' may be defined in an untracked
;; `.dir-locals.el`, so do this from the main worktree.
(-when-let* ((wtree (caar (magit-list-worktrees)))
@@ -823,6 +823,18 @@ function."
(string-match "\\`https://github.com/[^/]+/[^/]+" url)
(match-string 0 url))))
+(defun km/magit-github-url-from-origin ()
+ (when-let ((origin (magit-get "remote.origin.url")))
+ (and (string-match (rx "git@github.com:"
+ (group (one-or-more (not (any "."))))
+ (zero-or-one ".git"))
+ origin)
+ (concat "https://github.com/" (match-string 1 origin)))))
+
+(defun km/magit-github-url ()
+ (or (km/magit-github-url-from-bugref)
+ (km/magit-github-url-from-origin)))
+
(defun km/magit-github-file-link ()
(let ((ln (lambda (loc)
(save-restriction