Skip to content

Commit 1d9bef3

Browse files
committed
Merge pull request #1 from ghmulti/master
exception handling, logging
2 parents ca53ccf + 3ec22d0 commit 1d9bef3

3 files changed

Lines changed: 18 additions & 15 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
/lib
33
/classes
44
/checkouts
5+
.idea
56
pom.xml
67
*.jar
78
*.class
89
.lein-deps-sum
910
.lein-failures
10-
.lein-plugins
11+
.lein-plugins
12+
*.iml

src/lein_git_version_generate/plugin.clj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
clojure.pprint
55
[leiningen.git-version :only [git-version]]))
66

7-
(defn wrap-with-hook [f & args]
8-
(do
9-
(apply git-version args)
10-
(apply f args)))
7+
(defn wrap-with-hook [f & args]
8+
(do
9+
(try
10+
(apply git-version args)
11+
(catch Exception e (println "lein-git-version plugin: exception " (.getMessage e))))
12+
(apply f args)))
1113

1214
(defn hooks []
1315
(robert.hooke/add-hook #'leiningen.compile/compile #'wrap-with-hook))

src/leiningen/git_version.clj

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,23 @@
1010
(:use
1111
[clojure.java.shell :only [sh]]))
1212

13+
(defn shcall [& args]
14+
(let [{exit :exit out :out err :err} (apply sh args)
15+
exitcode (clojure.string/trim (str exit))]
16+
(when-not (= "0" exitcode) (println "lein-git-version plugin: sh call " args " exit code " exitcode " error " err))
17+
(apply str (rest (clojure.string/trim out)))))
18+
1319
(defn get-git-version
1420
[]
15-
(apply str (rest (clojure.string/trim
16-
(:out (sh
17-
"git" "describe" "--match" "v*.*"
18-
"--abbrev=4" "--dirty=**DIRTY**"))))))
21+
(shcall "git" "describe" "--match" "v*.*" "--abbrev=4" "--dirty=**DIRTY**"))
1922

2023
(defn get-git-ref
2124
[]
22-
(apply str (clojure.string/trim
23-
(:out (sh
24-
"git" "rev-parse" "--verify" "HEAD")))))
25+
(shcall "git" "rev-parse" "--verify" "HEAD"))
2526

2627
(defn get-git-status
2728
[]
28-
(apply str (clojure.string/trim
29-
(:out (sh
30-
"git" "status" "--porcelain")))))
29+
(shcall "git" "status" "--porcelain"))
3130

3231
;(defn git-version
3332
; "Show project version, as tagged in git."

0 commit comments

Comments
 (0)