Пример #1
0
def _pull_issues(github_repository):
    issues = list(github_repository.get_issues(state='all'))
    for i in issues:
        [l.name for l in i.labels]

    print_info('Pulled {} issues from {}'.format(len(issues),
                                                 github_repository.url))
    return issues
Пример #2
0
def install_hooks(dest=None):
    hooks_source = pkg_resources.resource_filename(__name__, 'hook_files')
    if dest is None:
        root = repo_root()
        dest = os.path.join(root, '.git/hooks')
    print_info('Installing hooks into {}'.format(dest))
    copy_directory(hooks_source, dest)
    print_info('Successfully installed hooks')
Пример #3
0
def _pull_issues(github_repository):
    issues = list(github_repository.get_issues(state='all', direction='asc'))

    # trigger necessary API requests for lazily loaded labels
    for issue in issues:
        [label.name for label in issue.labels]

    print_info('Pulled {} issues from {}'.format(len(issues), github_repository.url))
    return issues
Пример #4
0
def pull_from_project_manager(system_yml_path, cache_dir=None):
    system = load_yaml(system_yml_path)

    if system['project_management_tool'] == 'GitHub Issue':
        from rdm.backends.github_issue import pull
    elif system['project_management_tool'] == 'GitHub PR':
        from rdm.backends.github_pr import pull
    else:
        raise ValueError("Project management tool not supported.")

    development_history = pull(system, cache_dir)
    print_info('Found {} change(s)'.format(len(
        development_history['changes'])))
    print_info('Found {} change_requests(s)'.format(
        len(development_history['change_requests'])))
    write_yaml(development_history, sys.stdout)
Пример #5
0
def authenticate_github():
    gh_api_token = os.getenv('GH_API_TOKEN', None)
    if gh_api_token:
        print_info('Using API token stored in GH_API_TOKEN.')
        return Github(gh_api_token)
    else:
        print_info('No access token is stored in the GH_API_TOKEN environment variable.')
        help_url = 'https://help.github.com/en/articles/' + \
            'creating-a-personal-access-token-for-the-command-line'
        print_info('See ' + help_url + 'for details.')
        print_info('Defaulting to username / password for login.')
        username = input('GitHub username: '******'GitHub password (will not echo to console): ')
        return Github(username, password)
Пример #6
0
def _pull_cached(get_data, filename, label):
    try:
        with open(filename, 'rb') as f:
            data = pickle.load(f)
        print_info('Loaded {} cached {} from {}'.format(
            len(data), label, filename))
    except Exception:
        print_info('Unable to load cached {} from {}'.format(label, filename))
        data = get_data()
        with open(filename, 'wb') as f:
            pickle.dump(data, f)
        print_info('Saved {} cached {} to {}'.format(len(data), label,
                                                     filename))
    return data
Пример #7
0
def _pull_pull_requests(github_repository):
    pull_requests = list(github_repository.get_pulls(state='closed', direction='asc'))
    print_info('Pulled {} pull requests from {}'.format(len(pull_requests), github_repository.url))
    return pull_requests