Skip to content

Commit

Permalink
[refactor] renames linkable-objects to formattable-objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedek Fazekas committed Jan 8, 2015
1 parent 34bfc67 commit 79616ea
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
Binary file modified bin/gargamel.jar
Binary file not shown.
16 changes: 1 addition & 15 deletions gargamel-html.edn
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
{:sections
;; defines sections in the changelog
;; key: identifier for the section
;; regex: to select changes for a section
;; title: title for the section
;;
;; later section definition has precedence over previous ones
[{:key :fixes :regex ".*#\\d+.*" :title "New features, bugfixes"}
{:key :wip :regex ".*\\[[Ww][iI][pP]\\].*" :title "Work in progress, not yet ready"}]
:linkable-objects
;; defines custom transformations on text chunks, can be used for links in the changelog (commit hashes are turned into links automatically)
;; template: the template fragment to use
;; regex: to select bits of text to be transformed
;;
;; all selected text fragments are run through a format string with two arguments:
;; first is org/user name second is project name. See the %1$s style place holders.
;; for more info on format string see: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html
;; After that the regex groups are replaced
:formattable-objects
[{:template "<a href=\"https://github.com/%1$s/%2$s/issues/$1\"> #$1</a>" :regex "#(\\d+)"}
{:template "<a href=\"https://github.com/$2/issues/$3\">$2: $3</a>" :regex "(([_\\w/-]+)#(\\d+))"}
{:template "<span style=\"color: red; font-weight: bold;\">$1</span>" :regex "(\\[refactor\\])"}
Expand Down
7 changes: 6 additions & 1 deletion gargamel.edn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;; later section definition has precedence over previous ones
[{:key :fixes :regex ".*#\\d+.*" :title "New features, bugfixes"}
{:key :wip :regex ".*\\[[Ww][iI][pP]\\].*" :title "Work in progress, not yet ready"}]
:linkable-objects
:formattable-objects
;; defines custom transformations on text chunks, can be used for links in the changelog (commit hashes are turned into links automatically)
;; template: the template fragment to use
;; regex: to select bits of text to be transformed
Expand All @@ -20,5 +20,10 @@
{:template "[$2: $3](https://github.com/$2/issues/$3)" :regex "(([_\\w/-]+)#(\\d+))"}
{:template "`$1`" :regex "(\\[refactor\\])"}
{:template "$1 " :regex "(\\n)"}]

;; directory for custom templates. should contain a template named changelog.mustache
;; which might include other templates mustache style with {{> othertemplate}}
:template-dir "md-templates"

;; file extension for the output
:output-extension ".md"}
6 changes: 3 additions & 3 deletions src/leiningen/gargamel.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

(def ^:dynamic target-path nil)

(def ^:private linkable-objects-defaults
(def ^:private formattable-objects-defaults
[{:template "<a href=\"https://github.com/%1$s/%2$s/issues/$1\"> #$1</a>" :regex "#(\\d+)"}
{:template "<a href=\"https://github.com/$2/issues/$3\">$2: $3</a>" :regex "(([_\\w/-]+)#(\\d+))"}
{:template "<a href=\"http://andjira.and.dmgt.net:8080/browse/$1\">$1</a>" :regex "(MOL-\\d+)"}
Expand Down Expand Up @@ -62,8 +62,8 @@

(defn issues->links [source-dir commit]
(let [org-name (git/org-or-username (git/remote-url source-dir))
linkable-objects (or (:linkable-objects project-config) linkable-objects-defaults)
i->l (fn [t] (reduce #(str/replace %1 (-> %2 :regex re-pattern) (-> %2 :template (format org-name proj-name))) t linkable-objects))
formattable-objects (or (:formattable-objects project-config) formattable-objects-defaults)
i->l (fn [t] (reduce #(str/replace %1 (-> %2 :regex re-pattern) (-> %2 :template (format org-name proj-name))) t formattable-objects))
subject (-> commit
:subject
i->l)
Expand Down
2 changes: 1 addition & 1 deletion test/gargamel/test_html_changelog_gen.clj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{:key :technical :regex ".*#(\\d+).*" :title "Internal changes"}
{:key :business :regex ".*(MOL-\\d+).*" :title "Business related changes"}
{:key :geo :regex ".*Geo.*" :title "Geo related changes"}]
:linkable-objects
:formattable-objects
[{:template "<a href=\"https://github.com/%1$s/%2$s/issues/$1\"> #$1</a>" :regex "#(\\d+)"}
{:template "<a href=\"https://github.com/$2/issues/$3\">$2: $3</a>" :regex "(([_\\w/-]+)#(\\d+))"}
{:template "<a href=\"http://andjira.and.dmgt.net:8080/browse/$1\">$1</a>" :regex "(MOL-\\d+)"}
Expand Down

0 comments on commit 79616ea

Please sign in to comment.