Skip to content

Commit

Permalink
Merge pull request technomancy#2630 from chrisglass/fix/annotate-rele…
Browse files Browse the repository at this point in the history
…ase-tags

Make sure release tags are annotated
  • Loading branch information
technomancy authored Nov 17, 2019
2 parents d30da96 + 942e4e8 commit 88fad0e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
13 changes: 9 additions & 4 deletions src/leiningen/vcs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
(or (:vcs project) (some (partial uses-vcs project) @supported-systems)))

(defn parse-tag-args [args]
(loop [parsed-args {:sign? true}
(loop [parsed-args {:sign? true :annotate? 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))
"--annotate" (recur (assoc parsed-args :annotate? true) (rest args))
"--no-annotate" (recur (assoc parsed-args :annotate? false) (rest args))
nil parsed-args ;; We're finished and can exit
(recur (assoc parsed-args :prefix (first args)) (rest args)))))

Expand All @@ -40,7 +42,10 @@
string for the commit message that will be provided the version."
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, or --no-annotate to create
non-release tags."
which-vcs :default :none)

(defmulti assert-committed "Abort if uncommitted changes exist."
Expand Down Expand Up @@ -79,11 +84,11 @@

(defmethod tag :git [{:keys [root version]} & args]
(binding [eval/*dir* root]
(let [{:keys [sign? prefix]} (parse-tag-args args)
(let [{:keys [annotate? sign? prefix]} (parse-tag-args args)
tag (if prefix
(str prefix version)
version)
cmd (->> ["git" "tag" (when sign? "--sign") tag "-m" (str "Release " version)]
cmd (->> ["git" "tag" (when sign? "--sign") tag (when annotate? "-a") "-m" (str "Release " version)]
(filter some?))]
(apply eval/sh-with-exit-code "Couldn't tag" cmd))))

Expand Down
19 changes: 11 additions & 8 deletions test/leiningen/test/vcs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
(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})))
[] {:sign? true :annotate? true}
["v"] {:prefix "v" :sign? true :annotate? true}
["v" "--sign"] {:prefix "v" :sign? true :annotate? true}
["--sign"] {:sign? true :annotate? true}
["--no-sign"] {:sign? false :annotate? true}
["--no-sign" "v"] {:prefix "v" :sign? false :annotate? true}
["--no-annotate"] {:sign? true :annotate? false}
["--annotate"] {:sign? true :annotate? true}
["--no-sign" "--no-annotate" "v"] {:sign? false :annotate? false :prefix "v"}
["-s"] {:sign? true :annotate? true}
["v" "r"] {:prefix "r" :sign? true :annotate? true})))

0 comments on commit 88fad0e

Please sign in to comment.