summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
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