-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #22 in 0.4.6 by adding Leiningen release stub
- Loading branch information
1 parent
d43853d
commit 0ec21bb
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(ns leiningen.release | ||
"Adapted from Leiningen's code by stripping things down to | ||
just one method to support one particular template (play-clj) | ||
that uses lein-droid, which expects parse-semantic-version | ||
to be available here." | ||
(:require [boot.util :as util])) | ||
|
||
(defn string->semantic-version | ||
"Create map representing the given version string. Returns nil if the | ||
string does not follow guidelines setforth by Semantic Versioning 2.0.0, | ||
http://semver.org/" | ||
[version-string] | ||
;; <MajorVersion>.<MinorVersion>.<PatchVersion>[-<Qualifier>][-SNAPSHOT] | ||
(if-let [[_ major minor patch qualifier snapshot] | ||
(re-matches | ||
#"(\d+)\.(\d+)\.(\d+)(?:-(?!SNAPSHOT)([^\-]+))?(?:-(SNAPSHOT))?" | ||
version-string)] | ||
(->> [major minor patch] | ||
(map #(Integer/parseInt %)) | ||
(zipmap [:major :minor :patch]) | ||
(merge {:qualifier qualifier | ||
:snapshot snapshot})))) | ||
|
||
(defn parse-semantic-version | ||
"Create map representing the given version string. Aborts with exit code 1 | ||
if the string does not follow guidelines setforth by Semantic Versioning 2.0.0, | ||
http://semver.org/" | ||
[version-string] | ||
(or (string->semantic-version version-string) | ||
(util/exit-error (println "Unrecognized version string:" version-string)))) |