Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Sep 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/DEPLOY.md
Expand Up @@ -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
Expand Down
23 changes: 17 additions & 6 deletions src/leiningen/vcs.clj
Expand Up @@ -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."
Expand All @@ -31,7 +39,6 @@
(defmulti assert-committed "Abort if uncommitted changes exist."
which-vcs :default :none)



;;; VCS not found

Expand All @@ -48,6 +55,7 @@

(defmethod assert-committed :none [project] (unknown-vcs "assert-committed"))


;;; Git

(defmethod push :git [project & args]
Expand All @@ -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)]
Expand Down
15 changes: 15 additions & 0 deletions test/leiningen/test/vcs.clj
@@ -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})))