3131 (str " Execution of Git command failed: " stderr)))))))
3232
3333(defn git-describe-log-lines [log-lines-seq]
34- " Given a seq of \" git log\" output lines, return map with :git-tag (most recent tag)
35- and :git-tag-delta (number of commits to reach it)"
34+ " Given a seq of \" git log\" output lines, return map with :git-tag (most recent
35+ tag) and :git-tag-delta (number of commits to reach it)"
3636 (loop [i 0 , lines log-lines-seq]
3737 (let [line (first lines)
3838 [_ hash tag] (re-find #"^(\w +) .*tag: (v[^\)\, ]+).*" line)]
4242 [tag i]))))
4343
4444(defn git-describe-first-parent [dir]
45- " Return map with :git-tag (most recent tag on current branch (always following \" first-parent\" on merges))
46- and :git-tag-delta (number of commits -couting on first-parent paths only- from :git-tag to HEAD) "
45+ " Return map with :git-tag (most recent tag on current branch (always following
46+ \" first-parent\" on merges)) and :git-tag-delta (number of commits -couting on
47+ first-parent paths only- from :git-tag to HEAD)"
4748
4849 (let [p (run-git dir [" log" " --oneline" " --decorate=short" " --first-parent" ])
4950 lines (line-seq (reader (:out p)))
@@ -58,33 +59,35 @@ and :git-tag-delta (number of commits -couting on first-parent paths only- from
5859 " Infer the current project version from tags on the source-control system"
5960
6061 (binding [*debug-fn* debug-fn, *git-cmd* git-cmd]
61- (let [commit-tstamp (-> (run-git-wait dir [" log" " -n" " 1" " --format=%ct" ])
62- trim-newline
63- (Long/parseLong )
64- (* 1000 )
65- Date.)
66- format-str (or tstamp-format " yyyyMMddHHmmss" )
67- commit-tstamp-str (.format (SimpleDateFormat. format-str)
68- commit-tstamp)
62+ (let [commit-tstamp (-> (run-git-wait dir [" log" " -n" " 1" " --format=%ct" ])
63+ trim-newline
64+ (Long/parseLong )
65+ (* 1000 )
66+ Date.)
67+ format-str (or tstamp-format " yyyyMMddHHmmss" )
68+ commit-tstamp-str (.format (SimpleDateFormat. format-str)
69+ commit-tstamp)
6970
70- [short-hash long-hash] (split
71- (run-git-wait dir [ " log" " -n" " 1" " --format=%h %H" ])
72- #" " )
71+ [short-hash long-hash] (split
72+ (run-git-wait dir
73+ [" log" " -n" " 1" " --format=%h %H" ])
74+ #" " )
7375
74- versioning-properties {:build-tag " N/A"
75- :build-version " N/A"
76- :build-tag-delta " 0"
77- :build-tstamp commit-tstamp-str
78- :build-commit long-hash
79- :build-commit-abbrev short-hash }
80-
81- {:keys [git-tag git-tag-delta] } (git-describe-first-parent dir)]
82-
83- (if (nil? git-tag)
84- versioning-properties
76+ versioning-properties {:build-tag " N/A"
77+ :build-version " N/A"
78+ :build-tag-delta " 0"
79+ :build-tstamp commit-tstamp-str
80+ :build-commit long-hash
81+ :build-commit-abbrev short-hash }
8582
86- (let [maven-artifact-version ((re-find #"v(.*)" git-tag) 1 )]
87- (merge versioning-properties
88- {:build-tag maven-artifact-version
89- :build-version (str (replace-first git-tag #"^v" " " ) " -" git-tag-delta " -" short-hash)
90- :build-tag-delta (str git-tag-delta) }))))))
83+ {:keys [git-tag git-tag-delta] } (git-describe-first-parent dir)]
84+
85+ (if (nil? git-tag)
86+ versioning-properties
87+
88+ (let [maven-artifact-version ((re-find #"v(.*)" git-tag) 1 )]
89+ (merge versioning-properties
90+ {:build-tag maven-artifact-version
91+ :build-version (str (replace-first git-tag #"^v" " " ) " -"
92+ git-tag-delta " -" short-hash)
93+ :build-tag-delta (str git-tag-delta) }))))))
0 commit comments