Configure git-link for sourcegraph
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment