summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2021-09-09 16:34:16 -0700
committerFranck Cuny <franck@fcuny.net>2021-09-09 16:34:16 -0700
commit8faab69e06d6ae6522847b7bf2a87053073dc8b6 (patch)
tree64b347ac64af4b43f69a640bab843bd2733e074d
parentMakefile: simplify the setup (diff)
downloademacs.d-8faab69e06d6ae6522847b7bf2a87053073dc8b6.tar.gz
emacs: use default branch for sourcegraph
Don't use the current branch when building a link to sourcegraph, as we might be on a feature branch that is not available on the remote.
-rw-r--r--emacs/custom/fcuny-git.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/emacs/custom/fcuny-git.el b/emacs/custom/fcuny-git.el
index 4c6409a..9761309 100644
--- a/emacs/custom/fcuny-git.el
+++ b/emacs/custom/fcuny-git.el
@@ -86,6 +86,7 @@
(use-package git-link
:ensure t
+ :after magit
:bind (("C-c g l" . git-link)
("C-c g a" . git-link-commit))
:config
@@ -93,8 +94,14 @@
(format "sourcegraph.twitter.biz/%s" hostname))
(defun fcuny/git-link-work-sourcegraph (hostname dirname filename _branch commit start end)
- (let ((sg-base-url (fcuny/get-sg-remote-from-hostname hostname)))
- (git-link-sourcegraph sg-base-url dirname filename _branch commit start end)))
+ ;;; For a given repository, build the proper link for sourcegraph.
+ ;;; Use the default branch of the repository instead of the
+ ;;; current one (we might be on a feature branch that is not
+ ;;; available on the remote).
+ (require 'magit-branch)
+ (let ((sg-base-url (fcuny/get-sg-remote-from-hostname hostname))
+ (main-branch (magit-main-branch)))
+ (git-link-sourcegraph sg-base-url dirname filename main-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)))