mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
Add modules/feature/version-control
This commit is contained in:
32
modules/feature/version-control/autoload.el
Normal file
32
modules/feature/version-control/autoload.el
Normal file
@ -0,0 +1,32 @@
|
||||
;;; feature/version-control/autoload.el
|
||||
|
||||
;;;###autoload
|
||||
(defun +vcs-git-root ()
|
||||
"Get git url root."
|
||||
(-when-let (url (car-safe (browse-at-remote--remote-ref buffer-file-name)))
|
||||
(cdr (browse-at-remote--get-url-from-remote url))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vcs/git-browse ()
|
||||
"Open the website for the current (or specified) version controlled FILE.
|
||||
Fallback to repository root."
|
||||
(interactive)
|
||||
(let (url)
|
||||
(condition-case err
|
||||
(setq url (browse-at-remote-get-url))
|
||||
(error
|
||||
(setq url (shell-command-to-string "hub browse -u --"))
|
||||
(setq url (if url
|
||||
(concat (s-trim url) "/" (f-relative (buffer-file-name) (doom-project-root))
|
||||
(when (use-region-p) (format "#L%s-L%s"
|
||||
(line-number-at-pos (region-beginning))
|
||||
(line-number-at-pos (region-end)))))))))
|
||||
(when url (browse-url url))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vcs/git-browse-issues ()
|
||||
"Open the github issues page for current repo."
|
||||
(interactive)
|
||||
(if-let (root (+vcs-git-root))
|
||||
(browse-url (concat root "/issues"))
|
||||
(user-error "No git root found!")))
|
Reference in New Issue
Block a user