Example #1
0
def create_issue(jira_issue):
    "Creates a `survivor.models.Issue` from a `jira.resources.Issue`."
    issue = Issue(
        key=jira_issue.key,
        title=jira_issue.fields.description,
        state=jira_issue.fields.status.name.lower(),
        opened=iso8601.parse_date(jira_issue.fields.created),
        updated=iso8601.parse_date(jira_issue.fields.updated),
        url=jira_issue.self,
    )

    if jira_issue.fields.reporter is not None:
        issue.reporter = get_or_create_user(jira_issue.fields.reporter)
    else:
        issue.reporter = get_or_create_user(jira_issue.fields.assignee)

    if jira_issue.fields.resolutiondate:
        issue.closed = iso8601.parse_date(jira_issue.fields.resolutiondate)
        resolution_type = jira_issue.fields.resolution.name
        issue.finished_or_fixed = resolution_type == "Finished" or resolution_type == "Fixed"

    if jira_issue.fields.assignee:
        issue.assignee = get_or_create_user(jira_issue.fields.assignee)

    # TODO comments, labels

    return issue.save()
Example #2
0
def create_issue(github_issue):
    "Creates a `survivor.models.Issue` from a `github.Issue`."
    params = {}

    for issue_attr, github_attr in issue_attr_map.items():
        # Make all attribues as list of attributes
        if not isinstance(github_attr, list):
            github_attr = [github_attr]

        if issue_attr == 'labels':
            labels = getattr(github_issue, 'labels')
            value = [label.name for label in labels]
        else:
            # Drill done through each attribute in the order given
            value = github_issue
            for attr in github_attr:
                if value:
                    value = getattr(value, attr)
        params[issue_attr] = value

    issue = Issue(**params)

    issue.reporter = get_or_create_user(github_issue.user)
    if github_issue.assignee:
        issue.assignee = get_or_create_user(github_issue.assignee)

    # TODO comments, labels

    return issue.save()
Example #3
0
def create_issue(github_issue):
    "Creates a `survivor.models.Issue` from a `github.Issue`."
    issue = Issue(**dict((issue_attr, getattr(github_issue, github_attr))
                         for issue_attr, github_attr in issue_attr_map.items()))

    issue.reporter = get_or_create_user(github_issue.user)
    if github_issue.assignee:
        issue.assignee = get_or_create_user(github_issue.assignee)

    # TODO comments, labels

    return issue.save()