예제 #1
0
def fetch_pull_request_details(api: GithubRepoAPI,
                               detailed_pull_requests: Mapping[int, Mapping]):
    pull_request_details: Dict[int, Dict[str, Any]] = {
        p: {}
        for p in detailed_pull_requests.keys()
    }
    for pull_request in detailed_pull_requests.values():
        pr_commits = api.fetch_commits(
            pull_request_number=pull_request['number'])
        last_commit_sha = pr_commits[-1]['sha'] if pr_commits else None
        pull_request_details[
            pull_request['number']]['last_commit_sha'] = last_commit_sha

        last_status = api.fetch_commit_status(
            last_commit_sha) if last_commit_sha else None
        pull_request_details[
            pull_request['number']]['statuses_info'] = last_status

        reviews = api.fetch_commit_reviews(
            last_commit_sha) if last_commit_sha else None
        last_review = max(
            reviews,
            key=operator.itemgetter('submitted_at')) if reviews else None
        pull_request_details[
            pull_request['number']]['last_review'] = last_review

        pr_comments = api.fetch_pull_request_comments(pull_request['number'])
        pull_request_details[pull_request['number']]['comments'] = pr_comments
    return pull_request_details
예제 #2
0
def get_repos_names(
    owner: str,
    github_login: str,
    github_token: str,
    skip_archived: bool,
) -> List[str]:
    repos = GithubRepoAPI(owner, None, github_login,
                          github_token).fetch_repos_list() or []
    if skip_archived:
        repos = [r for r in repos if not r['archived']]
    repos.sort(key=operator.itemgetter('updated_at'))
    return [r['name'] for r in reversed(repos)]
예제 #3
0
def github_api():
    return GithubRepoAPI(
        owner='test',
        repo_name='test',
        github_login='******',
        github_api_token='123',
    )
예제 #4
0
def create_api(
    owner: str,
    repo_name: str,
    github_login: str,
    github_api_token: str,
) -> GithubRepoAPI:
    return GithubRepoAPI(owner, repo_name, github_login, github_api_token)
예제 #5
0
def fetch_detailed_pull_requests(api: GithubRepoAPI, open_pull_requests):
    pull_requests = {}
    for pull_request in open_pull_requests:
        pr = api.fetch_pull_request(pull_request['number'])
        if pr:
            pull_requests[pr['number']] = pr
    return pull_requests
예제 #6
0
def fetch_last_commit_date(api: GithubRepoAPI):
    commits = api.fetch_commits()
    last_commit_date = None
    if commits:
        raw_date = commits[0]['commit']['committer']['date']
        last_commit_date = datetime.datetime.fromisoformat(raw_date[:-1])
    return last_commit_date
예제 #7
0
def fetch_ow_repo_config(api: GithubRepoAPI, config_file_name: str,
                         config_section_name: str):
    config = {}
    config_file_content = api.fetch_file_contents(config_file_name)
    if config_file_content:
        parser = configparser.ConfigParser()
        parser.read_string(config_file_content)
        config = dict(parser[config_section_name]
                      ) if config_section_name in parser else {}
    return config
예제 #8
0
def fetch_open_pull_requests(api: GithubRepoAPI):
    return api.fetch_open_pull_requests()
예제 #9
0
def fetch_issues_comments(api: GithubRepoAPI, open_issues):
    return {
        i['number']: api.fetch_issue_comments(i['number'])
        for i in open_issues
    }
예제 #10
0
def fetch_open_issues(api: GithubRepoAPI):
    return api.fetch_open_issues()
예제 #11
0
def fetch_repo_info(api: GithubRepoAPI):
    return api.fetch_repo_info()
예제 #12
0
def fetch_file_with_package_name_content(api: GithubRepoAPI,
                                         package_name_path: str):
    return api.fetch_file_contents(package_name_path.split(':')[0], )
예제 #13
0
def fetch_ci_config_content(api: GithubRepoAPI, ci_config_file_name: str):
    return api.fetch_file_contents(ci_config_file_name)
예제 #14
0
def fetch_readme_content(api: GithubRepoAPI,
                         readme_file_name: str) -> Optional[str]:
    return api.fetch_file_contents(readme_file_name)