diff options
author | Franck Cuny <franck@fcuny.net> | 2023-06-01 19:35:59 -0700 |
---|---|---|
committer | Franck Cuny <franck@fcuny.net> | 2023-06-01 19:35:59 -0700 |
commit | a187752c824b47052d33d3bc12749b5a7d2e8191 (patch) | |
tree | d939397496dcae8a7634a93b159fab57ee1752ec /emacs/elisp/my-git-extra.el | |
parent | elfeed: add more feeds (diff) | |
download | emacs.d-a187752c824b47052d33d3bc12749b5a7d2e8191.tar.gz |
🤡
Change-Id: I06b104d79deac199f9cd9cdae705e333d23cc852
Diffstat (limited to '')
-rw-r--r-- | emacs/elisp/my-git-extra.el | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/emacs/elisp/my-git-extra.el b/emacs/elisp/my-git-extra.el deleted file mode 100644 index 30fff78..0000000 --- a/emacs/elisp/my-git-extra.el +++ /dev/null @@ -1,50 +0,0 @@ -;;; my-git-extra.el --- Extra functions to work with git -;;; Commentary: -;;; Code: - -(require 'magit) -(require 'git-link) - -(defun my/clone-repo (url) - "Clone a repository in the workspace using URL." - (interactive "sURL:") - (let* ((repo-name (magit-clone--url-to-name url)) - (target-dir (concat "~/workspace/" repo-name))) - (magit-clone-regular url target-dir nil))) - -(defun my/sg-instance (hostname) - "Return the base URL for a sourcegraph instance based on HOSTNAME." - (cond ((string-match "cl\.fcuny\.net" hostname) (format "cs.fcuny.xyz/%s" hostname)) - (t (format "sourcegraph.rbx.com/%s" hostname)))) - -(defun my/git-link-sourcegraph (hostname dirname filename _branch commit start end) - "Create a link to sourcegraph given a HOSTNAME DIRNAME FILENAME _BRANCH COMMIT START and END." - (let ((sg-base-url (my/sg-instance hostname)) - ;; 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). - (main-branch (magit-main-branch)) - ;; repositories cloned with gerrit have a "a/" prefix which we - ;; need to remove, as it's not part of the repository name in - ;; sourcegraph. - (dirname (replace-regexp-in-string "a\/" "" dirname))) - (git-link-sourcegraph sg-base-url dirname filename main-branch commit start end))) - -(defun my/git-link-commit-sourcegraph (hostname dirname commit) - "Create the link to sourcegraph given a HOSTNAME DIRNAME and COMMIT." - (let ((sg-base-url (my/sg-instance hostname)) - (dirname (replace-regexp-in-string "a\/" "" dirname))) - (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 '("github\\.rbx\\.com" my/git-link-sourcegraph)) -(add-to-list 'git-link-commit-remote-alist '("github\\.rbx\\.com" my/git-link-work-sourcegraph)) - -;; for personal code I use cgit and gerrit -(add-to-list 'git-link-remote-alist '("git\\.fcuny\\.net" my/git-link-sourcegraph)) -(add-to-list 'git-link-remote-alist '("cl\\.fcuny\\.net" my/git-link-sourcegraph)) -(add-to-list 'git-link-commit-remote-alist '("git\\.fcuny\\.net" my/git-link-commit-sourcegraph)) -(add-to-list 'git-link-commit-remote-alist '("cl\\.fcuny\\.net" my/git-link-commit-sourcegraph)) - -(provide 'my-git-extra) -;;; my-git-extra.el ends here |