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

Force writing of version.clj file #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
.lein-deps-sum
.lein-failures
.lein-plugins
.lein-plugins
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject org.clojars.cvillecsteele/lein-git-version "1.0.1"
(defproject org.clojars.brendanyounger/lein-git-version "1.0.5"
:description "Use git for project versions"
:url "https://github.com/cvillecsteele/lein-git-version"
:license {:name "Eclipse Public License"
Expand Down
27 changes: 13 additions & 14 deletions src/lein_git_version/plugin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
clojure.pprint
[leiningen.git-version :only [get-git-version]]))

(defn middleware
[project]
(let [code (str
";; Do not edit. Generated by lein-git-version plugin.\n"
"(ns " (:name project) ".version)\n"
"(def version \"" (get-git-version) "\")\n")
proj-dir (.toLowerCase (.replace (:name project) \- \_))
filename (if (:git-version-path project)
(str (:git-version-path project) "/version.clj")
(str (or (first (:source-paths project)) "src") "/"
proj-dir "/version.clj"))]
(-> project
(update-in [:injections] concat `[(spit ~filename ~code)])
(assoc :version (get-git-version)))))
(let [version (get-git-version)]
(defn middleware [project]
(let [code (str
";; Do not edit. Generated by lein-git-version plugin.\n"
"(ns " (:name project) ".version)\n"
"(def version \"" version "\")\n")
proj-dir (.toLowerCase (.replace (:name project) \- \_))
filename (if (:git-version-path project)
(str (:git-version-path project) "/version.clj")
(str (or (first (:source-paths project)) "src") "/"
proj-dir "/version.clj"))]
(spit filename code)
(assoc project :version version))))
8 changes: 2 additions & 6 deletions src/leiningen/git_version.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
(:use
[clojure.java.shell :only [sh]]))

(defn get-git-version
[]
(apply str (rest (clojure.string/trim
(:out (sh
"git" "describe" "--match" "v*.*"
"--abbrev=4" "--dirty=**DIRTY**"))))))
(defn get-git-version []
(clojure.string/trim (:out (sh "git" "describe" "--dirty"))))

(defn git-version
"Show project version, as tagged in git."
Expand Down