2018-07-31 16:33:16 +02:00
|
|
|
;;; emacs/vc/autoload/vc.el -*- lexical-binding: t; -*-
|
2017-02-03 20:29:09 -05:00
|
|
|
|
|
|
|
;;;###autoload
|
2018-06-21 21:14:00 +02:00
|
|
|
(defun +vc-git-root-url ()
|
2018-05-26 11:13:21 +02:00
|
|
|
"Return the root git repo URL for the current file."
|
2018-05-31 23:39:17 +10:00
|
|
|
(require 'git-link)
|
2018-05-26 11:13:21 +02:00
|
|
|
(let* ((remote (git-link--select-remote))
|
|
|
|
(remote-url (git-link--remote-url remote))
|
|
|
|
(remote-info (if remote-url (git-link--parse-remote remote-url))))
|
|
|
|
(if remote-info
|
|
|
|
(format "https://%s/%s" (car remote-info) (cadr remote-info))
|
2017-05-07 00:49:18 +02:00
|
|
|
(error "Remote `%s' is unknown or contains an unsupported URL" remote))))
|
2017-02-03 20:29:09 -05:00
|
|
|
|
2017-07-14 18:19:08 +02:00
|
|
|
(defvar git-link-open-in-browser)
|
2019-06-01 20:20:11 -04:00
|
|
|
(defvar git-link-use-commit)
|
2017-02-03 20:29:09 -05:00
|
|
|
;;;###autoload
|
2019-02-16 18:08:26 -05:00
|
|
|
(defun +vc/git-browse-region-or-line (&optional arg)
|
2017-04-22 21:27:54 -04:00
|
|
|
"Open the website for the current version controlled file. Fallback to
|
|
|
|
repository root."
|
2018-07-31 16:33:16 +02:00
|
|
|
(interactive "P")
|
2017-06-09 13:59:23 +02:00
|
|
|
(require 'git-link)
|
2019-06-01 20:20:11 -04:00
|
|
|
(let (git-link-use-commit)
|
|
|
|
(cl-destructuring-bind (beg end)
|
|
|
|
(if buffer-file-name (git-link--get-region))
|
|
|
|
(let ((git-link-open-in-browser (not arg)))
|
|
|
|
(git-link (git-link--select-remote) beg end)))))
|
2017-02-03 20:29:09 -05:00
|
|
|
|
2017-06-10 11:52:07 +02:00
|
|
|
;;;###autoload
|
2018-06-21 21:14:00 +02:00
|
|
|
(defun +vc*update-header-line (revision)
|
2018-02-07 02:27:06 -05:00
|
|
|
"Show revision details in the header-line, instead of the minibuffer.
|
|
|
|
|
|
|
|
Sometimes I forget `git-timemachine' is enabled in a buffer. Putting revision
|
|
|
|
info in the `header-line-format' is a good indication."
|
|
|
|
(let* ((date-relative (nth 3 revision))
|
|
|
|
(date-full (nth 4 revision))
|
|
|
|
(author (if git-timemachine-show-author (concat (nth 6 revision) ": ") ""))
|
|
|
|
(sha-or-subject (if (eq git-timemachine-minibuffer-detail 'commit) (car revision) (nth 5 revision))))
|
|
|
|
(setq header-line-format
|
|
|
|
(format "%s%s [%s (%s)]"
|
|
|
|
(propertize author 'face 'git-timemachine-minibuffer-author-face)
|
|
|
|
(propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face)
|
|
|
|
date-full date-relative))))
|