1010(defn run-git
1111 ([args] (run-git " ." args))
1212 ([project-dir args]
13- (sh/proc " bash " " -c " ( str " cd " project-dir " ; git " args ))))
13+ (apply sh/proc `( " git " ~@args :dir ~ project-dir))))
1414
1515(defn run-git-wait
1616 ([args] (run-git-wait " ." args))
1717 ([project-dir args]
18- (sh/stream-to-string (run-git project-dir args) :out )))
18+ (let [proc (run-git project-dir args)
19+ ok (zero? (sh/exit-code proc))
20+ stdout (sh/stream-to-string proc :out )
21+ stderr (sh/stream-to-string proc :err )]
22+ (if ok
23+ stdout
24+ (throw (RuntimeException.
25+ (str " Execution of Git command failed: " stderr)))))))
1926
2027(defn git-describe-log-lines [log-lines-seq]
2128 " Given a seq of \" git log\" output lines, return map with :git-tag (most recent tag)
3138 " Return map with :git-tag (most recent tag on current branch (always following \" first-parent\" on merges))
3239and :git-tag-delta (number of commits -couting on first-parent paths only- from :git-tag to HEAD) "
3340
34- (let [p (run-git dir " log --oneline --decorate=short --first-parent" )
41+ (let [p (run-git dir [ " log" " --oneline" " --decorate=short" " --first-parent" ] )
3542 lines (line-seq (reader (:out p)))
3643 [tag delta] (git-describe-log-lines lines)]
3744 (sh/destroy p)
@@ -41,7 +48,7 @@ and :git-tag-delta (number of commits -couting on first-parent paths only- from
4148 " Infer the current project version from tags on the source-control system"
4249
4350 (let [tstamp-format (:tstamp-format config-map)
44- commit-tstamp (-> (run-git-wait dir " log -n 1 --format=' %ct' " )
51+ commit-tstamp (-> (run-git-wait dir [ " log" " -n " " 1 " " --format=%ct" ] )
4552 trim-newline
4653 (Long/parseLong )
4754 (* 1000 )
@@ -51,7 +58,7 @@ and :git-tag-delta (number of commits -couting on first-parent paths only- from
5158 commit-tstamp)
5259
5360 [short-hash long-hash] (split
54- (run-git-wait dir " log -n 1 --format=' %h %H' " )
61+ (run-git-wait dir [ " log" " -n " " 1 " " --format=%h %H" ] )
5562 #" " )
5663
5764 versioning-properties {:build-tag " N/A"
0 commit comments