Skip to content

Commit

Permalink
Add conversion of #123 to ABC-123, so commit listing integration works.
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecordes committed Sep 29, 2012
1 parent 0eeb193 commit ccbcf53
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

; Maximum number of comments per issue
:maxcmt 25

; JIRA project setting - will be used to convert #123 to ABC-123
; so that source control integration still works.
:jira-project "ABC"

; Translate user names from
:user-map
Expand Down
19 changes: 14 additions & 5 deletions src/ghijira/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
(def ^:dynamic *auth*)
(def ^:dynamic *maxcmt*)
(def ^:dynamic *user-map*)
(def ^:dynamic *jira-project*)

; Use the all-pages mechanism in tentacles to retrieve a complete list
; of issues. I found that several of the GH export scripts on the web
Expand Down Expand Up @@ -101,16 +102,22 @@
(let [u (:login (:user issue))]
(get *user-map* u u)))

(defn sci-replace
""
[comment project]
(-> comment
(str/replace #"#(\d+)\b" (str project "-" "$1"))
(str/replace \# \_ ))) ; Drop #, JIRA does not like.

(defn format-comment [c]
(let [created-at (tf/parse gh-formatter (:created_at c))]
(let [created-at (tf/parse gh-formatter (:created_at c))
after-sci (sci-replace (:body c) *jira-project*)]
(str "Comment:"
(get-user c)
":"
(tf/unparse jira-formatter created-at)
":" \newline \newline
; JIRA thinks # means a comment in the CSV file, so drop those.
(str/replace (:body c) \# \_ )
)))
after-sci)))

(defn issue2row [issue]
(let [comments (take *maxcmt* (:comment-contents issue))]
Expand Down Expand Up @@ -160,7 +167,9 @@
*ghproject* (:ghproject config)
*auth* (:auth config)
*maxcmt* (:maxcmt config)
*user-map* (:user-map config)]
*user-map* (:user-map config)
*jira-project* (:jira-project config)
]
(let [issues (add-comments (get-all-issues))]
(warn-missing-issues issues)
(export-issues-to-file issues (str "JIRA-" *config-id* ".csv"))))))

0 comments on commit ccbcf53

Please sign in to comment.