Skip to content

Commit

Permalink
feat: possibly ignore webhooks by repo name
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-sentry committed Feb 13, 2024
1 parent ec0d738 commit d0538a9
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions webhook_handlers/views/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,20 @@ def push(self, request, *args, **kwargs):
)
return Response(data=WebhookHandlerErrorMessages.SKIP_NOT_ACTIVE)

push_webhook_ignore_repos = get_config(
"setup", "push_webhook_ignore_repo_names", default=[]
)
if repo.name in push_webhook_ignore_repos:
log.debug(

Check warning on line 256 in webhook_handlers/views/github.py

View check run for this annotation

Codecov - QA / codecov/patch

webhook_handlers/views/github.py#L256

Added line #L256 was not covered by tests

Check warning on line 256 in webhook_handlers/views/github.py

View check run for this annotation

Codecov Public QA / codecov/patch

webhook_handlers/views/github.py#L256

Added line #L256 was not covered by tests

Check warning on line 256 in webhook_handlers/views/github.py

View check run for this annotation

Codecov / codecov/patch

webhook_handlers/views/github.py#L256

Added line #L256 was not covered by tests

Check warning on line 256 in webhook_handlers/views/github.py

View check run for this annotation

Codecov - Staging / codecov/patch

webhook_handlers/views/github.py#L256

Added line #L256 was not covered by tests
"Codecov is configured to ignore this repository name",
extra=dict(
repoid=repo.repoid,
github_webhook_event=self.event,
repo_name=repo.name,
),
)
return Response(data=WebhookHandlerErrorMessages.SKIP_WEBHOOK_IGNORED)

Check warning on line 264 in webhook_handlers/views/github.py

View check run for this annotation

Codecov - QA / codecov/patch

webhook_handlers/views/github.py#L264

Added line #L264 was not covered by tests

Check warning on line 264 in webhook_handlers/views/github.py

View check run for this annotation

Codecov Public QA / codecov/patch

webhook_handlers/views/github.py#L264

Added line #L264 was not covered by tests

Check warning on line 264 in webhook_handlers/views/github.py

View check run for this annotation

Codecov / codecov/patch

webhook_handlers/views/github.py#L264

Added line #L264 was not covered by tests

Check warning on line 264 in webhook_handlers/views/github.py

View check run for this annotation

Codecov - Staging / codecov/patch

webhook_handlers/views/github.py#L264

Added line #L264 was not covered by tests

branch_name = self.request.data.get("ref")[11:]
commits = self.request.data.get("commits", [])

Expand Down Expand Up @@ -444,11 +458,11 @@ def _handle_installation_events(
if action == "deleted":

if event == GitHubWebhookEvents.INSTALLATION:
ghapp_installation: Optional[
GithubAppInstallation
] = owner.github_app_installations.filter(
installation_id=installation_id
).first()
ghapp_installation: Optional[GithubAppInstallation] = (
owner.github_app_installations.filter(
installation_id=installation_id
).first()
)
if ghapp_installation is not None:
ghapp_installation.delete()
# Deprecated flow - BEGIN
Expand Down

0 comments on commit d0538a9

Please sign in to comment.