Exemplo n.º 1
0
def triage_issue(location, issue):
    # https://developer.github.com/v3/issues/#edit-an-issue
    url = root + 'repos/{}/issues/{}'.format(location, issue['number'])
    labels = issue['labels']
    labels.append('triaged')
    res = requests.patch(url,
                         json={'labels': labels},
                         auth=(GITHUB_USERNAME, GITHUB_TOKEN))
    res.raise_for_status()
    notify_irc('Triage label added to {}#{}'.format(location, issue['number']))
Exemplo n.º 2
0
def triage_issue(location, issue):
    # https://developer.github.com/v3/issues/#edit-an-issue
    url = root + 'repos/{}/issues/{}'.format(location, issue['number'])
    labels = issue['labels']
    labels.append('triaged')
    res = requests.patch(
        url,
        json={'labels': labels},
        auth=(GITHUB_USERNAME, GITHUB_TOKEN)
    )
    res.raise_for_status()
    notify_irc('Triage label added to {}#{}'.format(location, issue['number']))
def close_pull_request(location, pull):
    # https://developer.github.com/v3/issues/comments/#create-a-comment
    url = repos + '{}/issues/{}/comments'.format(location, pull['number'])
    log.debug(url)
    res = requests.post(
        url,
        json={'body': message.format(location)},
        auth=(GITHUB_USERNAME, GITHUB_TOKEN)
    )
    res.raise_for_status()
    # https://developer.github.com/v3/pulls/#update-a-pull-request
    url = repos + '{}/pulls/{}'.format(location, pull['number'])
    log.debug(url)
    res = requests.patch(
        url,
        json={'state': 'closed'},
        auth=(GITHUB_USERNAME, GITHUB_TOKEN)
    )
    res.raise_for_status()
    notify_irc('Closed pull request {}#{}'.format(location, pull['number']))
Exemplo n.º 4
0
    # https://developer.github.com/v3/issues/comments/#create-a-comment
    url = repos + '{}/issues/{}/comments'.format(location, pull['number'])
    log.debug(url)
    res = requests.post(
        url,
        json={'body': message},
        auth=(GITHUB_USERNAME, GITHUB_TOKEN)
    )
    res.raise_for_status()


if __name__ == '__main__':
    location = sys.argv[1]
    assert '/' in location
    endpoint = sys.argv[2]
    assert endpoint.startswith('https://')

    log.info('Checking: {}'.format(location))

    pulls = list_pull_requests(location)
    log.info('Found: {} pull requests'.format(len(pulls)))
    commit_hash, commits_since = get_commits(location, endpoint)
    log.info('Found version on server and last 100 commits.')

    for pull in pulls:
        if check_deployed(pull, commit_hash, commits_since):
            comment_on_pull_request(location, pull)
            notify_irc('Commented on pull request: {}'.format(pull['number']))
            log.info('Commented on pull request: {}'.format(pull['number']))
        else:
            log.info('Pull request not deployed: {}'.format(pull['number']))
Exemplo n.º 5
0
    for issue in res.json()['items']:
        if issue['user']['login'] in developers:
            issues.append(issue)

    next_url = parse_link_headers(res.headers.get('link')).get('next')
    if next_url:
        _list_issues(next_url)


def triage_issue(location, issue):
    # https://developer.github.com/v3/issues/#edit-an-issue
    url = root + 'repos/{}/issues/{}'.format(location, issue['number'])
    labels = issue['labels']
    labels.append('triaged')
    res = requests.patch(url,
                         json={'labels': labels},
                         auth=(GITHUB_USERNAME, GITHUB_TOKEN))
    res.raise_for_status()
    notify_irc('Triage label added to {}#{}'.format(location, issue['number']))


if __name__ == '__main__':
    location = sys.argv[1]
    assert '/' in location
    notify_irc('Checking for bugs to triage in {}'.format(location))
    log.info('Checking: {}'.format(location))
    list_issues(location)
    for issue in issues:
        log.info('Automatic triage of: {}'.format(issue['number']))
        triage_issue(location, issue)
Exemplo n.º 6
0
        for line in stdout:
            if line.startswith('??'):
                git('add {}'.format(line[3:]))
            if line.startswith(' M'):
                git('add {}'.format(line[3:]))
            changed = True

        if changed:
            bump_version()
            git('branch changes-{}'.format(uid))
            git('checkout changes-{}'.format(uid))
            git('commit -m "changes from addons-robot {}" -a'.format(uid))
            git('push {} changes-{}'.format(target, uid))
            git('checkout master')
            return True

    return False


if __name__ == '__main__':
    uid = str(int(time.time()))
    setup()
    copy_files()
    commit = make_commit('addons-robot', uid)
    if commit:
        make_pull_request(commit, uid)
        notify_irc('Made pull request for {}'.format(dest_root))
    else:
        notify_irc('No changes needed for {}'.format(dest_root))
    url = repos + '{}/issues/{}/comments'.format(location, pull['number'])
    log.debug(url)
    res = requests.post(
        url,
        json={'body': message.format(location)},
        auth=(GITHUB_USERNAME, GITHUB_TOKEN)
    )
    res.raise_for_status()
    # https://developer.github.com/v3/pulls/#update-a-pull-request
    url = repos + '{}/pulls/{}'.format(location, pull['number'])
    log.debug(url)
    res = requests.patch(
        url,
        json={'state': 'closed'},
        auth=(GITHUB_USERNAME, GITHUB_TOKEN)
    )
    res.raise_for_status()
    notify_irc('Closed pull request {}#{}'.format(location, pull['number']))


if __name__ == '__main__':
    location = sys.argv[1]
    assert '/' in location
    notify_irc('Checking for pull requests to close in {}'.format(location))
    log.info('Checking: {}'.format(location))
    pulls = list_pull_requests(location)
    log.info('Found: {} pull requests since {}'.format(len(pulls), before))
    for pull in pulls:
        close_pull_request(location, pull)
        log.info('Successfully closed pull request: {}'.format(pull['number']))
Exemplo n.º 8
0
            issues.append(issue)

    next_url = parse_link_headers(res.headers.get('link')).get('next')
    if next_url:
        _list_issues(next_url)


def triage_issue(location, issue):
    # https://developer.github.com/v3/issues/#edit-an-issue
    url = root + 'repos/{}/issues/{}'.format(location, issue['number'])
    labels = issue['labels']
    labels.append('triaged')
    res = requests.patch(
        url,
        json={'labels': labels},
        auth=(GITHUB_USERNAME, GITHUB_TOKEN)
    )
    res.raise_for_status()
    notify_irc('Triage label added to {}#{}'.format(location, issue['number']))


if __name__ == '__main__':
    location = sys.argv[1]
    assert '/' in location
    notify_irc('Checking for bugs to triage in {}'.format(location))
    log.info('Checking: {}'.format(location))
    list_issues(location)
    for issue in issues:
        log.info('Automatic triage of: {}'.format(issue['number']))
        triage_issue(location, issue)