Basic support for tagging.
* magit.el (magit-tag, magit-annotated-tag): New. (magit-log-edit-commit): Run "git tag" when tag field is set. (magit-mode-map): Add them to 't' and 'T', respectively. (magit-mode-menu): Add them as well. (magit-pop-to-log-edit): New. (magit-log-edit): Use it after removing the tag field.
This commit is contained in:
parent
ee7070af15
commit
201822e96f
2 changed files with 42 additions and 7 deletions
39
magit.el
39
magit.el
|
@ -891,6 +891,8 @@ Many Magit faces inherit from this one by default."
|
||||||
(define-key map (kbd "F") 'magit-pull)
|
(define-key map (kbd "F") 'magit-pull)
|
||||||
(define-key map (kbd "c") 'magit-log-edit)
|
(define-key map (kbd "c") 'magit-log-edit)
|
||||||
(define-key map (kbd "C") 'magit-add-log)
|
(define-key map (kbd "C") 'magit-add-log)
|
||||||
|
(define-key map (kbd "t") 'magit-tag)
|
||||||
|
(define-key map (kbd "T") 'magit-annotated-tag)
|
||||||
(define-key map (kbd "$") 'magit-display-process)
|
(define-key map (kbd "$") 'magit-display-process)
|
||||||
(define-key map (kbd "q") 'quit-window)
|
(define-key map (kbd "q") 'quit-window)
|
||||||
map))
|
map))
|
||||||
|
@ -907,6 +909,8 @@ Many Magit faces inherit from this one by default."
|
||||||
["Unstage all" magit-unstage-all t]
|
["Unstage all" magit-unstage-all t]
|
||||||
["Commit" magit-log-edit t]
|
["Commit" magit-log-edit t]
|
||||||
["Add log entry" magit-add-log t]
|
["Add log entry" magit-add-log t]
|
||||||
|
["Tag" magit-tag t]
|
||||||
|
["Annotated tag" magit-annotated-tag t]
|
||||||
"---"
|
"---"
|
||||||
["Diff working tree" magit-diff-working-tree t]
|
["Diff working tree" magit-diff-working-tree t]
|
||||||
["Diff" magit-diff t]
|
["Diff" magit-diff t]
|
||||||
|
@ -1826,6 +1830,7 @@ Prefix arg means justify as well."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((fields (magit-log-edit-get-fields))
|
(let* ((fields (magit-log-edit-get-fields))
|
||||||
(amend (equal (cdr (assq 'amend fields)) "yes"))
|
(amend (equal (cdr (assq 'amend fields)) "yes"))
|
||||||
|
(tag (cdr (assq 'tag fields)))
|
||||||
(author (cdr (assq 'author fields))))
|
(author (cdr (assq 'author fields))))
|
||||||
(magit-log-edit-push-to-comment-ring (buffer-string))
|
(magit-log-edit-push-to-comment-ring (buffer-string))
|
||||||
(magit-log-edit-setup-author-env author)
|
(magit-log-edit-setup-author-env author)
|
||||||
|
@ -1835,10 +1840,15 @@ Prefix arg means justify as well."
|
||||||
(insert "(Empty description)\n"))
|
(insert "(Empty description)\n"))
|
||||||
(let ((commit-buf (current-buffer)))
|
(let ((commit-buf (current-buffer)))
|
||||||
(with-current-buffer (magit-find-buffer 'status default-directory)
|
(with-current-buffer (magit-find-buffer 'status default-directory)
|
||||||
(apply #'magit-run-with-input commit-buf
|
(cond (tag
|
||||||
"git" "commit" "-F" "-"
|
(magit-run-with-input commit-buf
|
||||||
(append (if (not (magit-anything-staged-p)) '("--all") '())
|
"git" "tag" tag "-a" "-F" "-"))
|
||||||
(if amend '("--amend") '())))))
|
(t
|
||||||
|
(apply #'magit-run-with-input commit-buf
|
||||||
|
"git" "commit" "-F" "-"
|
||||||
|
(append (if (not (magit-anything-staged-p))
|
||||||
|
'("--all") '())
|
||||||
|
(if amend '("--amend") '())))))))
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(bury-buffer)
|
(bury-buffer)
|
||||||
(when magit-pre-log-edit-window-configuration
|
(when magit-pre-log-edit-window-configuration
|
||||||
|
@ -1856,8 +1866,7 @@ Prefix arg means justify as well."
|
||||||
(magit-format-commit "HEAD" "%s%n%n%b")))
|
(magit-format-commit "HEAD" "%s%n%n%b")))
|
||||||
(magit-log-edit-set-fields fields)))
|
(magit-log-edit-set-fields fields)))
|
||||||
|
|
||||||
(defun magit-log-edit ()
|
(defun magit-pop-to-log-edit (operation)
|
||||||
(interactive)
|
|
||||||
(let ((dir default-directory)
|
(let ((dir default-directory)
|
||||||
(buf (get-buffer-create "*magit-log-edit*")))
|
(buf (get-buffer-create "*magit-log-edit*")))
|
||||||
(setq magit-pre-log-edit-window-configuration
|
(setq magit-pre-log-edit-window-configuration
|
||||||
|
@ -1865,7 +1874,12 @@ Prefix arg means justify as well."
|
||||||
(pop-to-buffer buf)
|
(pop-to-buffer buf)
|
||||||
(setq default-directory dir)
|
(setq default-directory dir)
|
||||||
(magit-log-edit-mode)
|
(magit-log-edit-mode)
|
||||||
(message "Type C-c C-c to commit.")))
|
(message "Type C-c C-c to %s." operation)))
|
||||||
|
|
||||||
|
(defun magit-log-edit ()
|
||||||
|
(interactive)
|
||||||
|
(magit-log-edit-set-field 'tag nil)
|
||||||
|
(magit-pop-to-log-edit "commit"))
|
||||||
|
|
||||||
(defun magit-add-log ()
|
(defun magit-add-log ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -1914,6 +1928,17 @@ Prefix arg means justify as well."
|
||||||
(newline))
|
(newline))
|
||||||
(insert (format "(%s): " fun))))))))))
|
(insert (format "(%s): " fun))))))))))
|
||||||
|
|
||||||
|
;;; Tags
|
||||||
|
|
||||||
|
(defun magit-tag (name)
|
||||||
|
(interactive "sNew tag name: ")
|
||||||
|
(magit-run "git" "tag" name))
|
||||||
|
|
||||||
|
(defun magit-annotated-tag (name)
|
||||||
|
(interactive "sNew tag name: ")
|
||||||
|
(magit-log-edit-set-field 'tag name)
|
||||||
|
(magit-pop-to-log-edit "tag"))
|
||||||
|
|
||||||
;;; Commits
|
;;; Commits
|
||||||
|
|
||||||
(defun magit-commit-at-point (&optional nil-ok-p)
|
(defun magit-commit-at-point (&optional nil-ok-p)
|
||||||
|
|
10
magit.texi
10
magit.texi
|
@ -273,6 +273,16 @@ restricted to that region.
|
||||||
|
|
||||||
Typing @kbd{v} will apply the selected changes in reverse.
|
Typing @kbd{v} will apply the selected changes in reverse.
|
||||||
|
|
||||||
|
@node Tagging
|
||||||
|
@chapter Tagging
|
||||||
|
|
||||||
|
Typing @kbd{t} will make a lighweight tag. Typing @kbd{T} will make a
|
||||||
|
annotated tag. It will put you in the normal @code{*magit-log-edit}
|
||||||
|
buffer for writing commit messages, but typing @kbd{C-c C-c} in it
|
||||||
|
will make the tag instead. This is controlled by the @code{Tag} field
|
||||||
|
that will be added to the @code{*magit-log-edit*} buffer. You can
|
||||||
|
edit it, if you like.
|
||||||
|
|
||||||
@node Resetting
|
@node Resetting
|
||||||
@chapter Resetting
|
@chapter Resetting
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue