From c93998816bf6b1bf553f2a56dde8d1ccee96d6f7 Mon Sep 17 00:00:00 2001 From: Tim Gilbert Date: Thu, 19 Jul 2018 11:03:01 -0400 Subject: [PATCH] Adding support for string version of :lein-v in project.clj --- README.md | 2 ++ src/lein_v/plugin.clj | 2 +- test/integration/lein_v/plugin.clj | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 947f977..194fb5a 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,8 @@ becomes this: Assuming that there is a git tag `v1.0.1` on the commit `HEAD~~`, and that the SHA of `HEAD` is uniquely identified by `abcd`. This behavior is automatically enabled whenever lein-v finds the project version to be the keyword `:lein-v`. +Note that the project version can be set to either the keyword `:lein-v` or the string `":lein-v"` (the Cursive IDE, in particular, gets confused by the keyword version). + ## Dependencies In case you're using a monorepository, you could also use lein-v to determine the current version of dependencies. diff --git a/src/lein_v/plugin.clj b/src/lein_v/plugin.clj index 4bcba23..f493502 100644 --- a/src/lein_v/plugin.clj +++ b/src/lein_v/plugin.clj @@ -5,7 +5,7 @@ (deploy-when-anchored)) (defn- select-versioner [version] - (if (= :lein-v version) + (if (#{:lein-v ":lein-v"} version) version-from-scm (do (when (and (string? version) (or (empty? version) (re-find #"lein" version))) (leiningen.core.main/warn "WARNING: lein-v is not managing this project's version. Set version in project.clj to :lein-v to trigger automatic lein-v management")) diff --git a/test/integration/lein_v/plugin.clj b/test/integration/lein_v/plugin.clj index e1d693d..d72307f 100644 --- a/test/integration/lein_v/plugin.clj +++ b/test/integration/lein_v/plugin.clj @@ -20,6 +20,17 @@ => (contains {:version "0.0.0" :manifest (contains {"Implementation-Version" "0.0.0"})})) +(fact "String version of :lein-v works correctly" + (against-background (before :facts (do (init!)))) + (middleware {:version ":lein-v" :v {:from-scm 'leiningen.v.maven/from-scm}}) + => (contains {:version "0.0.0" + :manifest (contains {"Implementation-Version" "0.0.0"})})) + +(fact "Non :lein-v version number is ignored" + (against-background (before :facts (do (init!)))) + (middleware {:version "1.2.3" :v {:from-scm 'leiningen.v.maven/from-scm}}) + => (contains {:version "1.2.3"})) + (fact "Baseless commit returns default + commit metadata" (against-background (before :facts (do (init!) (commit!)))) (middleware $mproject)