Skip to content

Commit

Permalink
fixes #5: linkable objects configurable
Browse files Browse the repository at this point in the history
- uses more concise data structure for linkable objects
- enables reading linkable object from gargamel.edn
  • Loading branch information
Benedek Fazekas committed Jan 7, 2015
1 parent 8b9092d commit 251131b
Show file tree
Hide file tree
Showing 4 changed files with 307 additions and 20 deletions.
Binary file modified bin/gargamel.jar
Binary file not shown.
26 changes: 6 additions & 20 deletions src/leiningen/gargamel.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,10 @@

(def ^:dynamic target-path nil)

(defn- github-issue-link [org-name proj-name]
(format "<a href=\"https://github.com/%s/%s/issues/$1\"> #$1</a>" org-name proj-name))

(def ^:private github-issue-link-external "<a href=\"https://github.com/$2/issues/$3\">$2: $3</a>")

(def ^:private github-issue-regexp-string "#(\\d+)")

(def ^:private github-issue-regexp (re-pattern github-issue-regexp-string))

(def ^:private github-external-issue-regexp #"(([_\w/-]+)#(\d+))")

(def ^:private jira-issue-link "<a href=\"http://andjira.and.dmgt.net:8080/browse/$1\">$1</a>")

(def ^:private jira-issue-regex-string "(MOL-\\d+)")

(def ^:private jira-issue-regex (re-pattern jira-issue-regex-string))
(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+)"}])

(def ^:private sections-defaults
[{:key :refactor :regex ".*refactor.*" :title "Refactorings, improvements"}
Expand Down Expand Up @@ -72,10 +60,8 @@

(defn issues->links [source-dir commit]
(let [org-name (git/org-or-username (git/remote-url source-dir))
i->l (fn [t] (-> t
(str/replace github-external-issue-regexp github-issue-link-external)
(str/replace github-issue-regexp (github-issue-link org-name proj-name))
(str/replace jira-issue-regex jira-issue-link)))
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))
subject (-> commit
:subject
i->l)
Expand Down
Loading

0 comments on commit 251131b

Please sign in to comment.