Sourcegraph is super useful when browsing through code and dependencies, there is currently no plugin for emacs, but it is pretty easy to configure git-link to do the trick as @sqs pointed out to me on Twitter.
This is all the configuration to make git-link work as expected, and it should be pretty generic.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; using https://github.com/jwiegley/use-package and https://github.com/sshaw/git-link | |
;; in the git config of the repository setup the following | |
;; [git-link] | |
;; remote = mysourcegraph.sourcegraph | |
;; [remote "mysourcegraph.sourcegraph"] | |
;; url = https://my.sourcegraph.host/my.git.host/myrespository | |
(use-package git-link | |
:ensure t | |
:config | |
(defun git-link-sourcegraph (hostname dirname filename _branch commit start end) | |
(let ((line-or-range (if end (format "%s-%s" start end) start))) | |
(format "https://%s/%s@%s/-/blob/%s#L%s" | |
hostname | |
dirname | |
commit | |
filename | |
line-or-range))) | |
(defun git-link-commit-sourcegraph (hostname dirname commit) | |
(format "https://%s/%s@%s" | |
hostname | |
dirname | |
commit)) | |
(add-to-list 'git-link-remote-alist '("sourcegraph" git-link-sourcegraph)) | |
(add-to-list 'git-link-commit-remote-alist '("sourcegraph" git-link-commit-sourcegraph)) | |
(setq git-link-open-in-browser 't)) |