From 6d3afb8184153f8b0080c27c71c9a6d54e3a7eb2 Mon Sep 17 00:00:00 2001 From: "sweep-nightly[bot]" <131841235+sweep-nightly[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 23:35:17 +0000 Subject: [PATCH 1/4] Added condition to check for 'sweep' label before processing 'check_run' completed event --- sweepai/api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sweepai/api.py b/sweepai/api.py index 1791bffa3b..c4603ad7bf 100644 --- a/sweepai/api.py +++ b/sweepai/api.py @@ -441,6 +441,9 @@ async def webhook(raw_request: Request): logger.info(f"Handling check suite for {request.repository.full_name}") _, g = get_github_client(request.installation.id) repo = g.get_repo(request.repository.full_name) + issue = repo.get_issue(request.check_run.pull_requests[0].number) + if not any(label.name == "sweep" for label in issue.labels): + return {"success": True} pull_request = repo.get_pull(request.check_run.pull_requests[0].number) if ( len(request.check_run.pull_requests) > 0 From cf38a3325f5c4440ba684f91cb4852296ba18d71 Mon Sep 17 00:00:00 2001 From: "sweep-nightly[bot]" <131841235+sweep-nightly[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 23:37:37 +0000 Subject: [PATCH 2/4] Added condition to check if check run has related pull requests and issue has labels --- sweepai/api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sweepai/api.py b/sweepai/api.py index c4603ad7bf..3a0af0024a 100644 --- a/sweepai/api.py +++ b/sweepai/api.py @@ -441,9 +441,11 @@ async def webhook(raw_request: Request): logger.info(f"Handling check suite for {request.repository.full_name}") _, g = get_github_client(request.installation.id) repo = g.get_repo(request.repository.full_name) - issue = repo.get_issue(request.check_run.pull_requests[0].number) - if not any(label.name == "sweep" for label in issue.labels): - return {"success": True} + if request.check_run.pull_requests and issue.labels: + if request.check_run.pull_requests and issue.labels: + issue = repo.get_issue(request.check_run.pull_requests[0].number) + if not any(label.name == "sweep" for label in issue.labels): + return {"success": True} pull_request = repo.get_pull(request.check_run.pull_requests[0].number) if ( len(request.check_run.pull_requests) > 0 From a8180efac35eabd7269ded1d99ddff845b46314b Mon Sep 17 00:00:00 2001 From: "sweep-nightly[bot]" <131841235+sweep-nightly[bot]@users.noreply.github.com> Date: Tue, 15 Aug 2023 23:40:09 +0000 Subject: [PATCH 3/4] Removed duplicate line in webhook function --- sweepai/api.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sweepai/api.py b/sweepai/api.py index 3a0af0024a..b55b82e0ba 100644 --- a/sweepai/api.py +++ b/sweepai/api.py @@ -441,7 +441,6 @@ async def webhook(raw_request: Request): logger.info(f"Handling check suite for {request.repository.full_name}") _, g = get_github_client(request.installation.id) repo = g.get_repo(request.repository.full_name) - if request.check_run.pull_requests and issue.labels: if request.check_run.pull_requests and issue.labels: issue = repo.get_issue(request.check_run.pull_requests[0].number) if not any(label.name == "sweep" for label in issue.labels): From 8a690796a8be0fc399e82f63a6fa2f7722a9d204 Mon Sep 17 00:00:00 2001 From: Kevin Lu Date: Tue, 15 Aug 2023 16:43:07 -0700 Subject: [PATCH 4/4] Update sweep.yaml --- sweep.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sweep.yaml b/sweep.yaml index e80c86cfbb..91a7fc2ebc 100644 --- a/sweep.yaml +++ b/sweep.yaml @@ -1,7 +1,7 @@ gha_enabled: True branch: main blocked_dirs: [".github/"] -draft: True +draft: False description: "sweepai/sweep is a python 3.10 project. The main api endpoints are in sweepai/api.py. Write code that adheres to PEP8." # These are the docs that we index for Sweep. # We scrape these docs once a day and store them in our database.