Exemplo n.º 1
0
def create_update_issue(project_id, issue_ref):
    api = GithubApi(token=config[project_id].GITHUB_TOKEN)
    github_issue = api.get('/repos/%s/issues/%s' % (config[project_id].TRACKER_PROJECT, issue_ref))
    if github_issue == None:
        return None
    
    issue = create_update_issue_from_github_issue(project_id, github_issue)
    update_button(project_id, github_issue)
    return issue
Exemplo n.º 2
0
def update_button(project, github_issue):
    issue_ref = github_issue.number
    body = github_issue.body
    body = remove_button(body)
    body = add_button(body, project, issue_ref)
    
    if body != github_issue.body:
        api = GithubApi(token=config[project.project_id].GITHUB_TOKEN)
        api.patch('/repos/%s/issues/%s' % (config[project.project_id].TRACKER_PROJECT, issue_ref), data=dict(body=body))
        return True

    return False
Exemplo n.º 3
0
def sync_issues(project_id):
    project = Project.query.get(project_id)
    api = GithubApi(token=config[project_id].GITHUB_TOKEN)
    updated_issues = []
    page = 1

    while True:
        github_issues = api.get('/repos/%s/issues' % config[project_id].TRACKER_PROJECT,
                per_page=RESULTS_PER_PAGE, page=page)

        if not github_issues:
            break

        for github_issue in github_issues:
            issue = create_update_issue_from_github_issue(project_id, github_issue)
            button = update_button(project, github_issue)
            if issue or button:
                updated_issues.append(github_issue.number)
        
        page += 1

    return updated_issues