Add option to not sign tags when running "vcs" "tag"

- Add vcs tag commandline argument parser
- Update documentation to show new options

Fixes #1873, fixes #1799
This commit is contained in:
Daniel Compton 2015-09-10 13:38:04 +12:00
parent 6538837be0
commit eb98e855cf
3 changed files with 39 additions and 6 deletions

View file

@ -297,6 +297,13 @@ libraries using Leiningen. Applications will have different requirements
that are varied enough that Leiningen doesn't attempt to support them
out of the box.
### Tagging
By default `["vcs" "tag"]` will create a GPG signed tag with your project version
number. You can add a tag prefix by passing the prefix after `"tag"`,
for example: `["vcs" "tag" "v"]`. You can disable tag signing by passing `--no-sign`,
for example: `["vcs" "tag" "v" "--no-sign"]` or `["vcs" "tag" "--no-sign"]`.
## Deploying to Maven Central
Deploying your libraries and other artifacts to [Maven

View file

@ -16,7 +16,15 @@
(defn which-vcs [project & _]
(or (:vcs project) (some (partial uses-vcs project) @supported-systems)))
(defn parse-tag-args [args]
(loop [parsed-args {:sign? true}
args args]
(case (first args)
("--sign" "-s") (recur (assoc parsed-args :sign? true) (rest args))
"--no-sign" (recur (assoc parsed-args :sign? false) (rest args))
nil parsed-args ;; We're finished and can exit
(recur (assoc parsed-args :prefix (first args)) (rest args)))))
;;; Methods
(defmulti push "Push to your remote repository."
@ -31,7 +39,6 @@
(defmulti assert-committed "Abort if uncommitted changes exist."
which-vcs :default :none)
;;; VCS not found
@ -48,6 +55,7 @@
(defmethod assert-committed :none [project] (unknown-vcs "assert-committed"))
;;; Git
(defmethod push :git [project & args]
@ -59,12 +67,15 @@
(binding [eval/*dir* (:root project)]
(eval/sh-with-exit-code "Couldn't commit" "git" "commit" "-a" "-m" (str "Version " (:version project)))))
(defmethod tag :git [{:keys [root version]} & [prefix]]
(defmethod tag :git [{:keys [root version]} & args]
(binding [eval/*dir* root]
(let [tag (if prefix
(let [{:keys [sign? prefix]} (parse-tag-args args)
tag (if prefix
(str prefix version)
version)]
(eval/sh-with-exit-code "Couldn't tag" "git" "tag" "-s" tag "-m" (str "Release " version)))))
version)
cmd (->> ["git" "tag" (when sign? "--sign") tag "-m" (str "Release " version)]
(filter some?))]
(apply eval/sh-with-exit-code "Couldn't tag" cmd))))
(defmethod assert-committed :git [project]
(binding [eval/*dir* (:root project)]

View file

@ -0,0 +1,15 @@
(ns leiningen.test.vcs
(:require [clojure.test :refer :all]
[leiningen.vcs :as vcs]))
(deftest parsed-args
(testing "VCS tag argument parsing"
(are [args parsed-args] (= (vcs/parse-tag-args args) parsed-args)
[] {:sign? true}
["v"] {:prefix "v" :sign? true}
["v" "--sign"] {:prefix "v" :sign? true}
["--sign"] {:sign? true}
["--no-sign"] {:sign? false}
["--no-sign" "v"] {:prefix "v" :sign? false}
["-s"] {:sign? true}
["v" "r"] {:prefix "r" :sign? true})))