Reappropriate bump-version
function for lein.change
usability
One wart to notice is that argument order is switched between `bump-version-map` and `bump-version`. This is because the `lein.change` semantics enforce that version-string is the first argument. Have not added tests for this function, do you think we should?
This commit is contained in:
parent
4ccec1a4a3
commit
c5bd294aa5
2 changed files with 11 additions and 5 deletions
|
@ -11,8 +11,7 @@
|
|||
(drop 1)
|
||||
(map #(Integer/parseInt %))
|
||||
(zipmap [:major :minor :patch]))
|
||||
qualifier (->> (re-matches #".*-(.+)?" version-string)
|
||||
(last))]
|
||||
qualifier (last (re-matches #".*-(.+)?" version-string))]
|
||||
(if-not (empty? version-map)
|
||||
(merge version-map {:qualifier qualifier})
|
||||
(throw (Exception. "Unrecognized version string.")))))
|
||||
|
@ -25,7 +24,7 @@
|
|||
(str major "." minor "." patch "-" qualifier)
|
||||
(str major "." minor "." patch))))
|
||||
|
||||
(defn bump-version
|
||||
(defn bump-version-map
|
||||
"Given version as a map of the sort returned by parse-semantic-version, return
|
||||
a map of the version incremented in the level argument. Add qualifier unless
|
||||
releasing non-snapshot."
|
||||
|
@ -36,7 +35,14 @@
|
|||
:patch {:major major :minor minor :patch (inc patch) :qualifier "SNAPSHOT"}
|
||||
:release {:major major :minor minor :patch patch}))
|
||||
|
||||
|
||||
(defn bump-version
|
||||
"Given a version string, return the bumped version string - incremented at the
|
||||
indicated level. Add qualifier unless releasing non-snapshot."
|
||||
[version-string level]
|
||||
(->> version-string
|
||||
parse-semantic-version
|
||||
(bump-version level)
|
||||
version-map->string))
|
||||
|
||||
(defn ^{:subtasks []} release
|
||||
"Perform release tasks.
|
||||
|
|
|
@ -66,5 +66,5 @@
|
|||
(doseq [[string parsed bumps] valid-semver-version-values]
|
||||
(is (= string (version-map->string parsed)))
|
||||
(doseq [[level string] bumps]
|
||||
(is (= (merge {:qualifier nil} (bump-version level parsed))
|
||||
(is (= (merge {:qualifier nil} (bump-version-map level parsed))
|
||||
(parse-semantic-version string))))))
|
||||
|
|
Loading…
Reference in a new issue