Function: magit-tag-release

magit-tag-release is an autoloaded, interactive and byte-compiled function defined in magit-tag.el.

Signature

(magit-tag-release TAG MSG &optional ARGS)

Documentation

Create a release tag for HEAD.

Assume that release tags match magit-release-tag-regexp.

If HEADs message matches magit-release-commit-regexp, then base the tag on the version string specified by that. Otherwise prompt for the name of the new tag using the highest existing tag as initial input and leaving it to the user to increment the desired part of the version string.

When creating an annotated tag, prepare a message based on the message of the highest existing tag, provided that contains the corresponding version string, and substituting the new version string for that. If that is not the case, propose a message using a reasonable format.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-tag.el
;;;###autoload
(defun magit-tag-release (tag msg &optional args)
  "Create a release tag for `HEAD'.

Assume that release tags match `magit-release-tag-regexp'.

If `HEAD's message matches `magit-release-commit-regexp', then
base the tag on the version string specified by that.  Otherwise
prompt for the name of the new tag using the highest existing
tag as initial input and leaving it to the user to increment the
desired part of the version string.

When creating an annotated tag, prepare a message based on the message
of the highest existing tag, provided that contains the corresponding
version string, and substituting the new version string for that.  If
that is not the case, propose a message using a reasonable format."
  (interactive
    (save-match-data
      (pcase-let*
          ((args (magit-tag-arguments))
           (`(,pver ,ptag ,pmsg) (car (magit--list-releases)))
           (msg (magit-rev-format "%s"))
           (ver (and (string-match magit-release-commit-regexp msg)
                     (match-str 1 msg)))
           (_   (and (not ver)
                     (require (quote sisyphus) nil t)
                     (string-match magit-release-commit-regexp
                                   (magit-rev-format "%s" ptag))
                     (user-error "Use `sisyphus-create-release' first")))
           (tag (cond
                  ((not ptag)
                   ;; Force the user to review the message used for the
                   ;; initial release tag, in case they do not like the
                   ;; default format.
                   (cl-pushnew "--edit" args :test #'equal)
                   (read-string "Create first release tag: "
                                (if (and ver (string-match-p "\\`[0-9]" ver))
                                    (concat "v" ver)
                                  ver)))
                  (ver
                   (concat (and (string-match magit-release-tag-regexp ptag)
                                (match-str 1 ptag))
                           ver))
                  ((read-string (format "Create release tag (previous was %s): "
                                        ptag)
                                ptag))))
           (ver (and (string-match magit-release-tag-regexp tag)
                     (match-str 2 tag))))
        (list tag
              (and (seq-some (apply-partially
                              #'string-match-p
                              "\\`--\\(annotate\\|local-user\\|sign\\)")
                             args)
                   (cond ((and pver (string-match (regexp-quote pver) pmsg))
                          (replace-match ver t t pmsg))
                         ((and ptag (string-match (regexp-quote ptag) pmsg))
                          (replace-match tag t t pmsg))
                         ((format "%s %s"
                                  (capitalize
                                   (file-name-nondirectory
                                    (directory-file-name (magit-toplevel))))
                                  ver))))
              args))))
  (magit-run-git-with-editor "tag" args (and msg (list "-m" msg)) tag)
  (set-process-sentinel
   magit-this-process
   (lambda (process event)
     (when (memq (process-status process) '(exit signal))
       (magit-process-sentinel process event)
       (magit-refs-setup-buffer "HEAD" (magit-show-refs-arguments))))))