Github issues to Pivotal Tracker

Today seemed like a good day to write a python script that generates a Pivotal Tracker friendly csv to import open Github issues using the github2 API.

We (dev @schipul) were using the GitHub issues list and Pivotal Tracker simultaneously and decided to move all our issues from Github so that we could organize it all in one place. It seemed logical because we use private repositories and the Github issues system is really geared towards socialization (not that we are anti-social or anything).

The only real thing you will need is the github2 api for python:

pip install github2

And use the script below to generate the CSV (modify as needed):
I also have a gist up with the same code here

import csv
from github2.client import Github

# api settings for github
git_username = 'your_git_username'
git_api_token = 'your_git_api_token'
git_repo = 'username/repo_name'

# import all issues as this story type
pivotal_story_type = 'Bug'

# csv name
csv_name = "open_git_hub_issues.csv"

def run_csv():
    """
    Export your open github issues into a csv format for
    pivotal tracker import
    """
    pivotal_csv = csv.writer(open(csv_name, 'wb'), delimiter=',')
    github = Github(username=git_username, api_token=git_api_token)

    # pivotals csv headers
    headers = [
        'Id',
        'Story',
        'Labels',
        'Story Type',
        'Estimate',
        'Current State',
        'Created At',
        'Accepted At',
        'Deadline',
        'Requested By',
        'Owned By',
        'Description',
        'Note',
        'Note'
    ]

    # write pivotals header rows
    pivotal_csv.writerow(headers)

    # get the git issues and write the rows to the csv
    git_issues = github.issues.list(git_repo, state="open")
    for git_issue in git_issues:
        labels = ','.join(git_issue.labels)

        # alot of these are blank because they are not really
        # needed but if you need them just fill them out
        story = [
            '', # id
            git_issue.title, # story
            labels, # labels
            pivotal_story_type, # story type
            '', # estimate
            '', # current stats
            git_issue.created_at, # created at
            '', # accepted at
            '', # deadline
            '', # requested by
            '', # owned by
            git_issue.body, # description
            '', # note 1
            '', # note 2
        ]
        pivotal_csv.writerow(story)

if __name__ == '__main__':
    run_csv()

Speak Your Mind

*


*

Fork me on GitHub