summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-08-24 10:06:32 -0700
committerFranck Cuny <franck@fcuny.net>2021-08-24 10:06:32 -0700
commit5216b2a119a5fa935705cc1df685ca869212c011 (patch)
treec6d3f3f5c0c3100215df34512bed29c5441fc0ea /emacs
parentemacs: git links to sourcegraph for work repo (diff)
downloademacs.d-5216b2a119a5fa935705cc1df685ca869212c011.tar.gz
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.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/custom/fcuny-git.el19
1 files 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))