예제 #1
0
파일: web.py 프로젝트: Dusk-Argentum/taine
    async def issues_handler(self, data):
        issue = data['issue']
        issue_num = issue['number']
        action = data['action']
        if issue['user']['login'] == 'taine-bot':
            return

        # we only really care about opened or closed
        if action == "closed":
            try:
                report = Report.from_github(issue_num)
            except ReportException:  # report not found
                return  # oh well

            await report.resolve(ContextProxy(self.bot), None, False)
            report.commit()
        elif action in ("opened", "reopened"):
            # is the issue new?
            try:
                report = Report.from_github(issue_num)
            except ReportException:  # report not found
                report = Report.from_issue(issue)
                await GitHubClient.get_instance().add_issue_comment(
                    issue['number'], f"Tracked as `{report.report_id}`.")

            await report.unresolve(ContextProxy(self.bot), None, False)
            report.commit()
예제 #2
0
파일: web.py 프로젝트: Croebh/taine
    async def report_opened(self, data):
        issue = data['issue']
        issue_num = issue['number']
        repo_name = data['repository']['full_name']
        # is the issue new?
        try:
            report = Report.from_github(repo_name, issue_num)
        except ReportException:  # report not found
            issue_labels = [lab['name'] for lab in issue['labels']]
            if EXEMPT_LABEL in issue_labels:
                return None

            report = Report.new_from_issue(repo_name, issue)
            if not issue['title'].startswith(report.report_id):
                formatted_title = f"{report.report_id} {report.title}"
                await GitHubClient.get_instance().rename_issue(
                    repo_name, issue['number'], formatted_title)

            # await GitHubClient.get_instance().add_issue_to_project(report.github_issue, report.is_bug)
            await GitHubClient.get_instance().add_issue_comment(
                repo_name, issue['number'],
                f"Tracked as `{report.report_id}`.")
            await report.update_labels()

        await report.unresolve(ContextProxy(self.bot), open_github_issue=False)
        report.commit()

        return report
예제 #3
0
파일: web.py 프로젝트: cfi2017/taine
    async def issues_handler(self, data):
        issue = data['issue']
        issue_num = issue['number']
        action = data['action']
        if data['sender']['login'] == 'taine-bot':
            return

        # we only really care about opened or closed
        if action == "closed":
            try:
                report = Report.from_github(issue_num)
            except ReportException:  # report not found
                return  # oh well

            await report.resolve(ContextProxy(self.bot),
                                 None,
                                 False,
                                 pend=True)
            report.commit()
        elif action in ("opened", "reopened"):
            # is the issue new?
            try:
                report = Report.from_github(issue_num)
            except ReportException:  # report not found
                report = Report.from_issue(issue)
                if not issue['title'].startswith(report.report_id):
                    formatted_title = re.sub(r'^([A-Z]{3}(-\d+)?\s)?',
                                             f"{report.report_id} ",
                                             issue['title'])
                    await GitHubClient.get_instance().rename_issue(
                        issue['number'], formatted_title)
                await GitHubClient.get_instance().add_issue_comment(
                    issue['number'], f"Tracked as `{report.report_id}`.")
                await report.update_labels()

            await report.unresolve(ContextProxy(self.bot), None, False)
            report.commit()
예제 #4
0
파일: web.py 프로젝트: Croebh/taine
    async def report_closed(self, data):
        issue = data['issue']
        issue_num = issue['number']
        repo_name = data['repository']['full_name']
        try:
            report = Report.from_github(repo_name, issue_num)
        except ReportException:  # report not found
            return  # oh well

        pend = data['sender']['login'] == constants.OWNER_GITHUB

        await report.resolve(ContextProxy(self.bot),
                             close_github_issue=False,
                             pend=pend)
        report.commit()
예제 #5
0
파일: web.py 프로젝트: cfi2017/taine
    async def issue_comment_handler(self, data):
        issue = data['issue']
        issue_num = issue['number']
        comment = data['comment']
        action = data['action']
        username = comment['user']['login']
        if username == "taine-bot":
            return  # don't infinitely add comments

        # only care about create
        if action == "created":
            try:
                report = Report.from_github(issue_num)
            except ReportException:
                return  # oh well

            await report.addnote(f"GitHub - {username}", comment['body'],
                                 ContextProxy(self.bot), False)
            report.commit()
            await report.update(ContextProxy(self.bot))
예제 #6
0
파일: web.py 프로젝트: Croebh/taine
    async def report_labeled(self, data):
        await asyncio.sleep(
            10)  # prevent a race condition when an issue is newly created
        issue = data['issue']
        issue_num = issue['number']
        repo_name = data['repository']['full_name']
        label_names = [l['name'] for l in issue['labels']]

        if len(
            [l for l in label_names if any(n in l
                                           for n in PRI_LABEL_NAMES)]) > 1:
            return  # multiple priority labels
        if len([
                l for l in label_names
                if l in (BUG_LABEL, FEATURE_LABEL, EXEMPT_LABEL)
        ]) > 1:
            return  # multiple type labels

        try:
            report = Report.from_github(repo_name, issue_num)
        except ReportException:  # report not found
            report = await self.report_opened(data)

        if report is None:  # this only happens if we try to create a report off an enhancement label
            return  # we don't want to track it anyway

        ctx = ContextProxy(self.bot)

        if EXEMPT_LABEL in label_names:  # issue changed from bug/fr to enhancement
            await report.untrack(ctx)
        else:
            priority = report.severity
            for i, pri in enumerate(PRI_LABEL_NAMES):
                if any(pri in n for n in label_names):
                    priority = i
                    break
            report.severity = priority
            report.is_bug = FEATURE_LABEL not in label_names
            await report.update(ctx)
            report.commit()