Last active
August 29, 2015 14:27
-
-
Save waynr/6678d74cc268704da0f3 to your computer and use it in GitHub Desktop.
Add arbitrary qualifier capability to leiningen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/projects/puppetlabs/puppet-server $ export LEIN=/home/wayne/projects/clojure/leiningen/bin/lein | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :release && lein pprint :version | |
"2.1.3" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :rc && lein pprint :version | |
"2.1.3-RC1" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :rc && lein pprint :version | |
"2.1.3-RC2" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :alpha && lein pprint :version | |
"2.1.3-alpha1" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :alpha && lein pprint :version | |
"2.1.3-alpha2" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :beta && lein pprint :version | |
"2.1.3-beta1" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :beta && lein pprint :version | |
"2.1.3-beta2" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :master && lein pprint :version | |
"2.1.3-master1" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :master && lein pprint :version | |
"2.1.3-master2" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :stable && lein pprint :version | |
"2.1.3-stable1" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :stable && lein pprint :version | |
"2.1.3-stable2" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :release && lein pprint :version | |
"2.1.3" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :future && lein pprint :version | |
"2.1.3-future1" | |
~/projects/puppetlabs/puppet-server $ $LEIN change version leiningen.release/bump-version :future && lein pprint :version | |
"2.1.3-future2" | |
~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/leiningen/release.clj b/src/leiningen/release.clj | |
index fb8f631..fcdcbcc 100644 | |
--- a/src/leiningen/release.clj | |
+++ b/src/leiningen/release.clj | |
@@ -15,7 +15,7 @@ | |
(drop 1) | |
(map #(Integer/parseInt %)) | |
(zipmap [:major :minor :patch])) | |
- qualifier (last (re-matches #".*-(.+)?" version-string))] | |
+ qualifier (last (re-matches #"\d+\.\d+\.\d+-(.+)?" version-string))] | |
(if-not (empty? version-map) | |
(merge version-map {:qualifier qualifier})))) | |
@@ -35,8 +35,8 @@ | |
(str major "." minor "." patch)))) | |
(defn next-qualifier [sublevel qualifier] | |
- (let [pattern (re-pattern (str sublevel "([0-9]+)")) | |
- [_ n] (and qualifier (re-find pattern qualifier))] | |
+ (let [pattern (re-pattern (str sublevel "([0-9]+)(-SNAPSHOT)*")) | |
+ [_ n _] (and qualifier (re-find pattern qualifier))] | |
(str sublevel (inc (Integer. (or n 0)))))) | |
(defn bump-version-map | |
@@ -54,7 +54,9 @@ | |
:qualifier (next-qualifier "beta" qualifier)} | |
:rc {:major major :minor minor :patch patch | |
:qualifier (next-qualifier "RC" qualifier)} | |
- :release {:major major :minor minor :patch patch})) | |
+ :release {:major major :minor minor :patch patch} | |
+ {:major major :minor minor :patch patch | |
+ :qualifier (next-qualifier (name level) qualifier)})) | |
(defn bump-version | |
"Given a version string, return the bumped version string - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment