Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit 635105a1ee523891f51753acd5e2952ed87cade2 0 parents
Kyle Cordes authored
26 .classpath
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/cheshire-4.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/clj-http-0.4.0.jar"/>
+ <classpathentry kind="lib" path="lib/clj-time-0.4.2.jar"/>
+ <classpathentry kind="lib" path="lib/clojure-1.4.0.jar"/>
+ <classpathentry kind="lib" path="lib/commons-codec-1.5.jar"/>
+ <classpathentry kind="lib" path="lib/commons-io-2.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
+ <classpathentry kind="lib" path="lib/core.incubator-0.1.0.jar"/>
+ <classpathentry kind="lib" path="lib/data.csv-0.1.2.jar"/>
+ <classpathentry kind="lib" path="lib/dev"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/httpcore-4.1.4.jar"/>
+ <classpathentry kind="lib" path="lib/httpmime-4.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/jackson-core-2.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/jackson-dataformat-smile-2.0.0.jar"/>
+ <classpathentry kind="lib" path="lib/joda-time-2.1.jar"/>
+ <classpathentry kind="lib" path="lib/pathetic-0.4.0.jar"/>
+ <classpathentry kind="lib" path="lib/slingshot-0.10.2.jar"/>
+ <classpathentry kind="lib" path="lib/tentacles-0.2.0-beta1.jar"/>
+ <classpathentry kind="lib" path="lib/url-0.0.6.jar"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
11 .gitignore
@@ -0,0 +1,11 @@
+/pom.xml
+*jar
+/lib
+/classes
+/native
+/.lein-failures
+/checkouts
+/.lein-deps-sum
+*.csv
+/config-OD
+*history*
20 .project
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ghijira</name>
+ <comment>Export GitHub Issues to JIRA-compatible CSV format</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>ccw.builder</name>
+ <arguments/>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments/>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>ccw.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
29 README
@@ -0,0 +1,29 @@
+# Export GitHub Issues to JIRA-compatible CSV format
+
+This software communicates with Github's v3 API, to export
+the "Issues" from a project in to a format JIRA can import.
+
+The source is set up for both leiningen and Eclipse, as I sometimes
+use the latter.
+
+Note that comment import is broken in JIRA import 4.1.4, and works
+correctly starting with JIRA import 4.2. As of June 2012, unfortunately
+the version deployed in JIRA OnDemand is 4.1.4.
+
+## Usage
+
+Use lein deps to download the dependencies.
+
+Edit config.clj with your project settings.
+
+Run the Clojure code, either in an IDE or via lein.
+
+Import the resulting JIRA.CSV file in to JIRA. A sample
+JIRA import configuration file is provided, the comment
+setting is required for comment import to work.
+
+## License
+
+Copyright (C) 2012 Kyle Cordes
+
+Distributed under the Eclipse Public License, the same as Clojure.
19 config-examples/JIRA-import-config-csv.txt
@@ -0,0 +1,19 @@
+{
+ "project.lead" : "YOUR JIRA USERNAME HERE",
+ "field.Date Modified" : "updated",
+ "field.Status" : "status",
+ "user.email.suffix" : "@example.com",
+ "field.Date Created" : "created",
+ "field.Summary" : "summary",
+ "field.Issue type" : "issuetype",
+ "field.Comments" : "comment",
+ "date.import.format" : "MM/dd/yy hh:mm:ss a",
+ "field.Description" : "description",
+ "date.fields" : "Date Created",
+ "field.Reporter" : "reporter",
+ "project.name" : "YOUR PROJECT NAME HERE",
+ "project.key" : "PROJ-KEY",
+ "mapfromcsv" : "false",
+ "field.Issue Id" : "issue-id",
+ "settings.advanced.mapper.comment" : "com.atlassian.jira.plugins.importer.imports.csv.mappers.PvcsComment"
+}
17 config.clj
@@ -0,0 +1,17 @@
+; Configuration setting for GHI -> JIRA CSV Export
+
+; Github login:
+(def auth "EMAIL:PASS")
+
+; Project owner and name:
+(def ghuser "github-user-goes-here")
+(def ghproject "project-name-here")
+
+; Maximum number of comments per issue
+(def MAXCMT 25)
+
+; Translate user names from
+(def user-map
+ { "GithubUserName1" "JIRAUserName1"
+ "GithubUserName2" "JIRAUserName2"
+ })
11 project.clj
@@ -0,0 +1,11 @@
+(defproject ghijira "1.0.0-SNAPSHOT"
+ :description "Export GitHub Issues to JIRA-compatible CSV format"
+ :dependencies [[org.clojure/clojure "1.4.0"]
+ [tentacles "0.2.0-beta1"]
+ [org.clojure/data.csv "0.1.2"]
+ [clj-time "0.4.2"]]
+
+ :dev-dependencies [
+ [lein-eclipse "1.0.0"]
+ ]
+)
97 src/ghijira/core.clj
@@ -0,0 +1,97 @@
+; Export GitHub Issues to JIRA-compatible CSV format
+
+; Copyright 2012 Kyle Cordes
+; http://kylecordes.com/
+
+; Hereby released under the Eclipse Public License 1.0,
+; the same license as Clojure uses.
+
+(ns ghijira.core
+ "Export GitHub Issues to JIRA-compatible CSV format"
+ (:require [clojure.pprint :as pp]
+ [clojure.string :only replace]
+ [clojure.data.csv :as csv]
+ [clojure.java.io :as io]
+ [tentacles.issues :as issues]
+ [clj-time.core :as time]
+ [clj-time.format :as tf] ))
+
+(load-file "config.clj")
+
+; 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
+; ignore everything past the first page, making them useless for all
+; but very small projects.
+
+; To test quickly with a smaller number of issues, change :all-pages true to
+; :per-page 20
+
+(def iss-open (issues/issues ghuser ghproject {:auth auth :all-pages true :state "open"}))
+(def iss-closed (issues/issues ghuser ghproject {:auth auth :all-pages true :state "closed"}))
+(def issues (concat iss-open iss-closed))
+
+(defn comments-for [issue]
+ (println (:number issue))
+ (issues/issue-comments ghuser ghproject (:number issue) {:auth auth}))
+
+; Load all the comments
+(def cmtmap (zipmap (map :number issues) (map comments-for issues)))
+
+(def columns
+ (concat
+ ["Issue Id",
+ "Summary",
+ "Description",
+ "Date Created",
+ "Date Modified",
+ "Issue type",
+ "Milestone",
+ "Status",
+ "Reporter"]
+ (repeat MAXCMT "Comments") ))
+
+; Date-time format used by the Github Issues API
+(def gh-formatter (tf/formatters :date-time-no-ms))
+
+; For most date fields, JIRA can handle anything in SimpleDateFormat
+; can be anything for SimpleDateFormat. For comment dates, JIRA requires
+; this specific format only.
+(def jira-formatter (tf/formatter "MM/dd/yy hh:mm:ss a"))
+
+(defn get-user [issue]
+ (let [u (:login (:user issue))]
+ (get user-map u u)))
+
+(defn format-comment [c]
+ (let [created-at (tf/parse gh-formatter (:created_at c))
+ ]
+ (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.
+ (clojure.string/replace (:body c) \# \_ )
+ )))
+
+(defn issue2row [issue]
+ (let [created-at (tf/parse gh-formatter (:created_at issue))
+ updated_at (tf/parse gh-formatter (:updated_at issue))
+ comments (take MAXCMT (cmtmap (:number issue)))]
+ (concat
+ (vector
+ (:number issue)
+ (:title issue)
+ (:body issue)
+ (tf/unparse jira-formatter created-at)
+ (tf/unparse jira-formatter updated_at)
+ "Task" ; issue type
+ (:title (:milestone issue))
+ (if (= "closed" (:state issue)) "Closed" "Open")
+ (get-user issue) )
+ (map format-comment comments)
+ (repeat (- MAXCMT (count comments)) "") ; pad out field count
+ )))
+
+(with-open [out-file (io/writer "JIRA.csv")]
+ (csv/write-csv out-file (concat [columns] (map issue2row issues))))
Please sign in to comment.
Something went wrong with that request. Please try again.