Skip to content

Commit

Permalink
fixes #7 and doc for -b option
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedek Fazekas committed Nov 20, 2014
1 parent e86a4c4 commit 91d2f7f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Binary file modified bin/gargamel.jar
Binary file not shown.
8 changes: 5 additions & 3 deletions src/gargamel/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
["-d" "--target-dir DIR" "Directory to generate create the changelog file in"
:default "."]
["-h" "--help"]
["-b" "--bower-dir DIR" "Location of bower components. Changelog for bower compenents added to the changelog if present"]
["-b" "--bower-dir DIR" "Directory where bower.json file is. Changelog for bower compenents added to the changelog if present"]
["-x" "--release-tag-pattern PATTERN" "Overrides default release tag pattern. Escape character classes with double \\, for example \\\\d"]
["-v" "--verbose"]])

(defn -main [& args]
(let [opts (cli/parse-opts args cli-options)
{:keys [from to latest-release project-name target-dir help bower-dir verbose]} (:options opts)
{:keys [from to latest-release project-name target-dir help bower-dir verbose release-tag-pattern]} (:options opts)
from-or-lr (or from latest-release)]

(when help
Expand All @@ -40,6 +41,7 @@
(println (str " from: " from))
(println (str " to: " to))
(println (str " latest-release: " latest-release))
(println (str " pattern:" release-tag-pattern))
(println (str " project-name: " project-name))
(println (str " target-dir: " target-dir))
(println (str " bower-dir " bower-dir)))
Expand All @@ -56,7 +58,7 @@
(grg/gargamel-changelog project-name target-dir from to))

(when (and (not bower-dir) latest-release)
(grg-lr/gargamel-latest-release-notes project-name target-dir))
(grg-lr/gargamel-latest-release-notes project-name target-dir release-tag-pattern))

(when (and bower-dir from)
(bower/bower-changelog bower-dir target-dir from to)))
Expand Down
19 changes: 12 additions & 7 deletions src/leiningen/gargamel_lr.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
[leiningen.gargamel :as gr]
[clojure.string :as str]))

(defn- latest-release-from-to []
(def ^:private default-release-tag-pattern
"release-\\d+-\\d+_\\d+")

(defn- latest-release-from-to [rt-pattern]
(->> (-> (sh/sh "git" "log" "--date=short" "--format=%h%;%cN;%d;%ad;%s;%b;" :dir ".")
:out
(str/split #";"))
(partition 6)
(map #(nth % 2))
(filter #(re-matches #".*release-.*" %))
(map #(str/replace % #".*(release-\d+-\d+_\d+).*" "$1"))
(filter #(re-matches (re-pattern (str ".*" rt-pattern ".*")) %))
(map #(str/replace % (re-pattern (str ".*(" rt-pattern ").*")) "$1"))
(take 2)
(reverse)))

(defn gargamel-latest-release-notes [proj-name target-dir]
(apply (partial gr/gargamel-changelog proj-name target-dir) (latest-release-from-to)))
(defn gargamel-latest-release-notes [proj-name target-dir rt-pattern]
(let [rt-pattern (or rt-pattern default-release-tag-pattern)]
(apply (partial gr/gargamel-changelog proj-name target-dir) (latest-release-from-to rt-pattern))))

(defn gargamel-lr
"Generates html changelog file between latest release tags.
Release tags format expected to be \"release-buildnumber-date_time\""
[project]
(apply (partial gr/gargamel project) (latest-release-from-to)))
[project & release-tag-pattern]
(let [rt-pattern (or (first release-tag-pattern) default-release-tag-pattern)]
(apply (partial gr/gargamel project) (latest-release-from-to rt-pattern))))

0 comments on commit 91d2f7f

Please sign in to comment.