Skip to content

Commit

Permalink
Factored out Github label retrieval/creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnschnur committed Sep 27, 2012
1 parent 395ddd6 commit 1c90732
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions migrateissues.py
Expand Up @@ -43,6 +43,15 @@ def github_escape(string):
return string.replace("%", "%")


def github_label(name, color = "FFFFFF"):

""" Returns the Github label with the given name, creating it if necessary. """

try: return github_repo.get_label(name)
except GithubException:
return github_repo.create_label(name, color)


def parse_gcode_id(id_text):

""" Returns the numeric part of a Google Code ID string. """
Expand Down Expand Up @@ -86,7 +95,7 @@ def add_issue_to_github(issue):
try: import_label = github_repo.get_label("imported")
except GithubException:
import_label = github_repo.create_label("imported", "FFFFFF")
github_issue.add_to_labels(import_label)
github_issue.add_to_labels(github_label("imported"))

# Assigns issues that originally had an owner to the current user

Expand All @@ -100,10 +109,7 @@ def add_issue_to_github(issue):
for label in issue.label:
label_text = LABEL_MAPPING.get(label.text, label.text)
if not options.dry_run:
try: github_label = github_repo.get_label(label_text)
except GithubException:
github_label = github_repo.create_label(label_text, "FFFFFF")
github_issue.add_to_labels(github_label)
github_issue.add_to_labels(github_label(label_text))
output(".")

return github_issue
Expand Down

0 comments on commit 1c90732

Please sign in to comment.