예제 #1
0
    def search_in_pr(
        self,
        pr_id: int,
        filter_regex: str,
        reverse: bool = False,
        description: bool = True,
    ) -> Optional[Match[str]]:
        """
        Find match in pull-request description or comments.

        :param description: bool (search in description?)
        :param pr_id: int
        :param filter_regex: filter the comments' content with re.search
        :param reverse: reverse order of comments
        :return: re.Match or None
        """
        all_comments: List[Any] = self.get_pr_comments(pr_id=pr_id, reverse=reverse)
        if description:
            description_content = self.get_pr_info(pr_id).description
            if reverse:
                all_comments.append(description_content)
            else:
                all_comments.insert(0, description_content)

        return search_in_comments(comments=all_comments, filter_regex=filter_regex)
예제 #2
0
def test_search_in_comments(comments, filter_str, starts_with, number_of_groups):
    match = search_in_comments(comments=comments, filter_regex=filter_str)
    if not number_of_groups:
        assert not match
    else:
        assert len(match.regs) == number_of_groups
        assert match.string.startswith(starts_with)
예제 #3
0
파일: base.py 프로젝트: pawelkopka/ogr
    def search(
        self, filter_regex: str, reverse: bool = False, description: bool = True
    ):
        all_comments: List[Any] = self.get_comments(reverse=reverse)
        if description:
            description_content = self.description
            if reverse:
                all_comments.append(description_content)
            else:
                all_comments.insert(0, description_content)

        return search_in_comments(comments=all_comments, filter_regex=filter_regex)