Allow overriding commit message

This gives the user control over the commit message when overriding the
default :release-tasks.

See #2308
This commit is contained in:
Toby Crawley 2017-09-09 10:29:25 -04:00
parent 05395e5fb2
commit 6606a910ab
No known key found for this signature in database
GPG key ID: 364085D369AF4381
2 changed files with 19 additions and 5 deletions

View file

@ -324,6 +324,12 @@ libraries using Leiningen. Applications will have different requirements
that are varied enough that Leiningen doesn't attempt to support them that are varied enough that Leiningen doesn't attempt to support them
out of the box. out of the box.
### Committing
By default, `["vcs" "commit"]` will commit with the message `"Version
<version>"`. You can override that by passing a `format`-ready string
to the task, like so: `["vcs" "commit" "Version %s [skip ci]"]`.
### Tagging ### Tagging
By default `["vcs" "tag"]` will create a GPG signed tag with your project version By default `["vcs" "tag"]` will create a GPG signed tag with your project version

View file

@ -28,12 +28,16 @@
nil parsed-args ;; We're finished and can exit nil parsed-args ;; We're finished and can exit
(recur (assoc parsed-args :prefix (first args)) (rest args))))) (recur (assoc parsed-args :prefix (first args)) (rest args)))))
(def default-commit-message "Version %s")
;;; Methods ;;; Methods
(defmulti push "Push to your remote repository." (defmulti push "Push to your remote repository."
which-vcs :default :none) which-vcs :default :none)
(defmulti commit "Commit changes to current repository." (defmulti commit
"Commit changes to current repository. Takes an optional format
string for the commit message that will be provided the version."
which-vcs :default :none) which-vcs :default :none)
(defmulti tag "Apply a version control tag. Takes an optional tag prefix. Pass --no-sign option to skip signing" (defmulti tag "Apply a version control tag. Takes an optional tag prefix. Pass --no-sign option to skip signing"
@ -52,7 +56,7 @@
(defmethod push :none [project & [args]] (unknown-vcs "push")) (defmethod push :none [project & [args]] (unknown-vcs "push"))
(defmethod commit :none [project] (unknown-vcs "commit")) (defmethod commit :none [project & _] (unknown-vcs "commit"))
(defmethod tag :none [project] (unknown-vcs "tag")) (defmethod tag :none [project] (unknown-vcs "tag"))
@ -65,9 +69,13 @@
(binding [eval/*dir* (:root project)] (binding [eval/*dir* (:root project)]
(apply eval/sh-with-exit-code "Couldn't push to the remote" "git" "push" "--follow-tags" args))) (apply eval/sh-with-exit-code "Couldn't push to the remote" "git" "push" "--follow-tags" args)))
(defmethod commit :git [project] (defmethod commit :git
(binding [eval/*dir* (:root project)] ([project]
(eval/sh-with-exit-code "Couldn't commit" "git" "commit" "-a" "-m" (str "Version " (:version project))))) (commit project default-commit-message))
([project message-template]
(binding [eval/*dir* (:root project)]
(let [message (format message-template (:version project))]
(eval/sh-with-exit-code "Couldn't commit" "git" "commit" "-a" "-m" message)))))
(defmethod tag :git [{:keys [root version]} & args] (defmethod tag :git [{:keys [root version]} & args]
(binding [eval/*dir* root] (binding [eval/*dir* root]