Skip to content

Commit

Permalink
more debugging, less modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Frazer Irving committed Jun 16, 2015
1 parent a8a8e7d commit 59cf696
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
26 changes: 16 additions & 10 deletions src/gargamel/bower.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,24 @@
(map #(s/replace % #"[^\d\.]" "") [x y]))


(defn include-module? [regex [module-key _]]
(when (and module-key regex (re-find regex (name module-key)))
true))

(defn changelog
([project-name project-dir from to]
(changelog project-name project-dir from to (atom #{})))
([project-name project-dir from to mods-seen]
([project-name project-dir from to {:keys [include-regex mods-seen]
:or {mods-seen (atom #{})}
:as opts}]
(println (format "Generating changelog for project %s between %s and %s"
project-name
from to))
(swap! mods-seen conj project-name)
(let [deps-before (:dependencies (config project-dir :rev from))
deps-after (:dependencies (config project-dir :rev to))
deps-changed (data/diff deps-before deps-after)
mods-changed (merge-with merge-versions (first deps-changed) (second deps-changed))
mods-pending (remove #(@mods-seen (key %)) mods-changed)
mods-pending (filter (partial include-module? include-regex) mods-pending)
changes (grg/changelog from to {:dir project-dir :name (name project-name)
:remote-url (git/remote-url project-dir)})]
(if mods-changed
Expand All @@ -43,14 +51,12 @@
:let [repo (lookup-module project-dir mod-name)
mod-dir (git/checkout-project mod-name repo)]]
(binding [grg/proj-name mod-name]
(changelog mod-name mod-dir mod-old-version mod-new-version mods-seen))))))
(changelog mod-name mod-dir mod-old-version mod-new-version opts))))))
changes))))

(defn bower-changelog [source-path target-path from to]
(defn bower-changelog [source-path target-path from to & opts]
(binding [grg/proj-name (:name (config source-path))
grg/target-path target-path]
(println (format "Generating changelog for project %s between %s and %s"
grg/proj-name
from to))
(grg/create-changelog (grg/enrich-changelog (changelog grg/proj-name source-path from to) source-path)
from to source-path)))
(grg/create-changelog (grg/enrich-changelog (changelog grg/proj-name source-path from to opts)
source-path)
from to source-path)))
11 changes: 8 additions & 3 deletions src/gargamel/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

(def cli-options
[
[nil "--bower-include-regex REGEX" "A regex of what bower modules to include" :default "."]
["-f" "--from FROM" "From ref (either commit hash or tag)"]
["-t" "--to TO" "To ref (either commit hash or tag). If empty defaults to HEAD."
:default "HEAD"]
Expand All @@ -31,7 +32,7 @@

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

(when help
Expand All @@ -44,7 +45,9 @@
(println (str " pattern:" release-tag-pattern))
(println (str " project-name: " project-name))
(println (str " target-dir: " target-dir))
(println (str " bower-dir " bower-dir)))
(println (str " bower-dir " bower-dir))
(println (str " bower-include-regex " bower-include-regex))
)

(when (and from latest-release)
(println "Either provide from and optionally to OR latest-release. Make up your mind!")
Expand All @@ -61,7 +64,9 @@
(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)))
(bower/bower-changelog bower-dir target-dir from to
:include-regex (re-pattern bower-include-regex)))
)

(println (first (shuffle gargamel-quotes)))
(System/exit 0))
2 changes: 2 additions & 0 deletions src/gargamel/git.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
(if (= pn "electrostatic") "f_electrostatic" pn))

(defn checkout-project [mod-name repo]
(println "Checking out" mod-name "from" repo)
(let [tmpdir (util/mk-tmp-dir (name mod-name))
tmpdir-name (.getAbsolutePath tmpdir)]
(when-not (.exists tmpdir) (.isDirectory tmpdir)
(throw (Exception. "Can't run git on non-existent dir " tmpdir-name)))
(sh/sh "git" "clone" repo tmpdir-name)
(println "Finished checking out" mod-name)
tmpdir))

(defn remote-url* [source-dir]
Expand Down

0 comments on commit 59cf696

Please sign in to comment.