示例#1
0
def last_commits(g, issue_ob: Issue, fast_mod=False):
    # 获取当前 issue 的关联 commit
    is_pr = issue_ob.pull_request
    # logger.debug(is_pr)
    this_repo = issue_ob.repository.full_name
    commits = []
    flag = False
    if is_pr is None:
        events = issue_ob.get_timeline()
        for event_it in events:
            if event_it.event == 'cross-referenced':
                ref_name, _ = util.re_issue(event_it.source.issue.html_url)
                if ref_name == this_repo:
                    if have_close_trigger(event_it.source.issue.body,
                                          issue_ob.number):
                        commits.append(
                            event_it.source.issue.pull_request.patch_url)
                        if fast_mod:
                            flag = True
                            break
            if event_it.commit_url:
                repo_name = re.findall(
                    r'https://api\.github\.com/repos/(.*?/[^/]*)/commits/([0-9a-zA-Z]+)',
                    event_it.commit_url)
                tmp_repo, sha = repo_name[0]
                repo = g.get_repo(tmp_repo)
                commit = repo.get_commit(sha)
                if tmp_repo == this_repo and commit.files:
                    commits.append(sha)
                    if fast_mod:
                        flag = True
                        break
    if fast_mod:
        return flag
    return this_repo, commits
示例#2
0
    def get_labels(issue: Issue) -> Dict[str, Dict[str, Union[int, str]]]:
        """Get non standalone labels by filtering them from all of the labels."""
        labels: Dict[str, Dict[str, Union[int, str]]] = {}

        for event in issue.get_timeline():

            if event.event != "labeled":
                continue

            label = event.__dict__.get("_rawData")["label"]
            if label["name"] in labels.keys():
                continue

            labels[label["name"]] = {
                "color": label["color"],
                "labeled_at": int(event.created_at.timestamp()),
                "labeler": event.actor.login,
            }

        return labels