Skip to content

Commit

Permalink
fixes #6 enables/demostrates markdown output
Browse files Browse the repository at this point in the history
- adds sample gargamel config commented for both html and markdown output
- adds sample templates for markdown output
  • Loading branch information
Benedek Fazekas committed Jan 7, 2015
1 parent f325840 commit 34bfc67
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 3 deletions.
Binary file modified bin/gargamel.jar
Binary file not shown.
22 changes: 22 additions & 0 deletions gargamel-html.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{: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
[{: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\\])"}
{:template "<br/>" :regex "(\\n)"}]}
24 changes: 24 additions & 0 deletions gargamel.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{: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
[{:template "[#$1](https://github.com/%1$s/%2$s/issues/$1)" :regex "#(\\d+)"}
{:template "[$2: $3](https://github.com/$2/issues/$3)" :regex "(([_\\w/-]+)#(\\d+))"}
{:template "`$1`" :regex "(\\[refactor\\])"}
{:template "$1 " :regex "(\\n)"}]
:template-dir "md-templates"
:output-extension ".md"}
22 changes: 22 additions & 0 deletions md-templates/changelog.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{^to-build-num}}
# Changelog for [{{to}}]({{to-url}})
{{/to-build-num}}
{{#to-build-num}}
# Changelog for build [{{to-build-num}}]({{to-url}}) created at {{to-time}}

VCS tag: {{to}}
{{/to-build-num}}
{{^from-build-num}}
## Changes since [{{from}}]({{from-url}}) ([diff](compare-url))
{{/from-build-num}}
{{#from-build-num}}
## Changes since build [{{from-build-num}}]({{from-url}}) created at {{from-time}} ([diff]({{compare-url}}))
VCS tag: {{from}}
{{/from-build-num}}
{{#sections}}

### {{title}}
{{#commits}}
{{> commit}}
{{/commits}}
{{/sections}}
3 changes: 3 additions & 0 deletions md-templates/commit.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* [{{hash}}]({{url}}) (*{{project-name}}*) {{date}} [{{commiter}}] **{{linked-subject}}**

{{linked-body}}
5 changes: 3 additions & 2 deletions src/leiningen/gargamel.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
(def ^:private linkable-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+)"}])
{:template "<a href=\"http://andjira.and.dmgt.net:8080/browse/$1\">$1</a>" :regex "(MOL-\\d+)"}
{:template "<br/>" :regex "(\\n)"}])

(def ^:private sections-defaults
[{:key :refactor :regex ".*refactor.*" :title "Refactorings, improvements"}
Expand Down Expand Up @@ -67,7 +68,7 @@
:subject
i->l)
body (-> commit :body i->l)]
(assoc commit :linked-body (str/replace body #"\n" "<br/>") :linked-subject subject)))
(assoc commit :linked-body body :linked-subject subject)))

(defn- create-section [sections-config commit]
(let [subject (:subject commit)
Expand Down
3 changes: 2 additions & 1 deletion test/gargamel/test_html_changelog_gen.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
[{: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+)"}
{:template "<a href=\"https://github.com/%1$s/%2$s/blob/master/README.md\">README</a>" :regex "README"}]})
{:template "<a href=\"https://github.com/%1$s/%2$s/blob/master/README.md\">README</a>" :regex "README"}
{:template "<br/>" :regex "(\\n)"}]})

(let [tmpdir (create-temp-dir "gargamel-test")]
(gargamel-changelog "clj_fe" (str tmpdir) "foobardir" "66e2387" "67f9576")
Expand Down

0 comments on commit 34bfc67

Please sign in to comment.