From 5216b2a119a5fa935705cc1df685ca869212c011 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Tue, 24 Aug 2021 10:06:32 -0700 Subject: emacs: fix mapping for git-link and simplify code The mapping for git.twitter.biz was incorrect. The package `git-link' has functions to take to format the URL for sourcegraph, we don't need to maintain them on our end, which simplifies a bit the code. --- emacs/custom/fcuny-git.el | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/emacs/custom/fcuny-git.el b/emacs/custom/fcuny-git.el index b85a9ea..97a9cfa 100644 --- a/emacs/custom/fcuny-git.el +++ b/emacs/custom/fcuny-git.el @@ -90,28 +90,19 @@ ("C-c g a" . git-link-commit)) :config (defvar fcuny/map-git-remote-to-sg - '(("git.twitter.biz" "sourcegraph.twitter.biz/twitter.biz") + '(("git.twitter.biz" "sourcegraph.twitter.biz/git.twitter.biz") ("gitpuppet.twitter.biz" "sourcegraph.twitter.biz/gitpuppet.twitter.biz"))) (defun fcuny/get-sg-remote-from-hostname (hostname) (nth 1 (assoc hostname fcuny/map-git-remote-to-sg))) (defun fcuny/git-link-work-sourcegraph (hostname dirname filename _branch commit start end) - (let ((line-or-range (if end (format "%s-%s" start end) start)) - (sg-base-url (fcuny/get-sg-remote-from-hostname hostname))) - (format "https://%s/%s@%s/-/blob/%s#L%s" - sg-base-url - dirname - commit - filename - line-or-range))) + (let ((sg-base-url (fcuny/get-sg-remote-from-hostname hostname))) + (git-link-sourcegraph sg-base-url dirname filename _branch commit start end))) (defun fcuny/git-link-commit-work-sourcegraph (hostname dirname commit) - (let (sg-base-url (fcuny/get-sg-remote-from-hostname hostname)) - (format "https://%s/%s/-/commit/%s" - sg-base-url - dirname - commit))) + (let ((sg-base-url (fcuny/get-sg-remote-from-hostname hostname))) + (git-link-commit-sourcegraph sg-base-url dirname commit))) ;; for work related repositories, open them in our instance of sourcegraph (add-to-list 'git-link-remote-alist '("twitter" fcuny/git-link-work-sourcegraph)) -- cgit 1.4.1