Skip to content

Instantly share code, notes, and snippets.

@sideshowcoder
Last active March 24, 2021 05:52

Revisions

  1. sideshowcoder renamed this gist Jul 2, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. sideshowcoder created this gist Jul 2, 2020.
    31 changes: 31 additions & 0 deletions git-link-sorucegraph.el
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    ;; 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))