Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/sentry/api/serializers/models/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,8 @@ class DetailedOrganizationSerializerResponse(_DetailedOrganizationSerializerResp
codecovAccess: bool
hideAiFeatures: bool
githubPRBot: bool
githubOpenPRBot: bool
githubNudgeInvite: bool
gitlabPRBot: bool
gitlabOpenPRBot: bool
aggregatedDataConsent: bool
genAIConsent: bool
isDynamicallySampled: bool
Expand Down Expand Up @@ -662,16 +660,10 @@ def serialize( # type: ignore[override]
obj.get_option("sentry:hide_ai_features", HIDE_AI_FEATURES_DEFAULT)
),
"githubPRBot": bool(obj.get_option("sentry:github_pr_bot", GITHUB_COMMENT_BOT_DEFAULT)),
"githubOpenPRBot": bool(
obj.get_option("sentry:github_open_pr_bot", GITHUB_COMMENT_BOT_DEFAULT)
),
"githubNudgeInvite": bool(
obj.get_option("sentry:github_nudge_invite", GITHUB_COMMENT_BOT_DEFAULT)
),
"gitlabPRBot": bool(obj.get_option("sentry:gitlab_pr_bot", GITLAB_COMMENT_BOT_DEFAULT)),
"gitlabOpenPRBot": bool(
obj.get_option("sentry:gitlab_open_pr_bot", GITLAB_COMMENT_BOT_DEFAULT)
),
"genAIConsent": bool(
obj.get_option("sentry:gen_ai_consent_v2024_11_14", DATA_CONSENT_DEFAULT)
),
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/apidocs/examples/organization_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,8 @@ class OrganizationExamples:
"codecovAccess": False,
"hideAiFeatures": False,
"githubPRBot": True,
"githubOpenPRBot": True,
"githubNudgeInvite": True,
"gitlabPRBot": True,
"gitlabOpenPRBot": True,
"aggregatedDataConsent": False,
"defaultAutofixAutomationTuning": AutofixAutomationTuningSettings.OFF,
"defaultSeerScannerAutomation": True,
Expand Down
22 changes: 0 additions & 22 deletions src/sentry/core/endpoints/organization_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,6 @@
bool,
GITHUB_COMMENT_BOT_DEFAULT,
),
(
"githubOpenPRBot",
"sentry:github_open_pr_bot",
bool,
GITHUB_COMMENT_BOT_DEFAULT,
),
(
"githubNudgeInvite",
"sentry:github_nudge_invite",
Expand All @@ -200,12 +194,6 @@
bool,
GITLAB_COMMENT_BOT_DEFAULT,
),
(
"gitlabOpenPRBot",
"sentry:gitlab_open_pr_bot",
bool,
GITLAB_COMMENT_BOT_DEFAULT,
),
(
"issueAlertsThreadFlag",
"sentry:issue_alerts_thread_flag",
Expand Down Expand Up @@ -310,11 +298,9 @@ class OrganizationSerializer(BaseOrganizationSerializer):
isEarlyAdopter = serializers.BooleanField(required=False)
hideAiFeatures = serializers.BooleanField(required=False)
codecovAccess = serializers.BooleanField(required=False)
githubOpenPRBot = serializers.BooleanField(required=False)
githubNudgeInvite = serializers.BooleanField(required=False)
githubPRBot = serializers.BooleanField(required=False)
gitlabPRBot = serializers.BooleanField(required=False)
gitlabOpenPRBot = serializers.BooleanField(required=False)
issueAlertsThreadFlag = serializers.BooleanField(required=False)
metricAlertsThreadFlag = serializers.BooleanField(required=False)
require2FA = serializers.BooleanField(required=False)
Expand Down Expand Up @@ -891,10 +877,6 @@ class OrganizationDetailsPutSerializer(serializers.Serializer):
help_text="Specify `true` to allow Sentry to comment on recent pull requests suspected of causing issues. Requires a GitHub integration.",
required=False,
)
githubOpenPRBot = serializers.BooleanField(
help_text="Specify `true` to allow Sentry to comment on open pull requests to show recent error issues for the code being changed. Requires a GitHub integration.",
required=False,
)
githubNudgeInvite = serializers.BooleanField(
help_text="Specify `true` to allow Sentry to detect users committing to your GitHub repositories that are not part of your Sentry organization. Requires a GitHub integration.",
required=False,
Expand All @@ -905,10 +887,6 @@ class OrganizationDetailsPutSerializer(serializers.Serializer):
help_text="Specify `true` to allow Sentry to comment on recent pull requests suspected of causing issues. Requires a GitLab integration.",
required=False,
)
gitlabOpenPRBot = serializers.BooleanField(
help_text="Specify `true` to allow Sentry to comment on open pull requests to show recent error issues for the code being changed. Requires a GitLab integration.",
required=False,
)

# slack features
issueAlertsThreadFlag = serializers.BooleanField(
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/integrations/github/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from .codecov_account_link import codecov_account_link
from .codecov_account_unlink import codecov_account_unlink
from .link_all_repos import link_all_repos
from .open_pr_comment import open_pr_comment_workflow
from .pr_comment import github_comment_workflow

__all__ = (
"codecov_account_link",
"codecov_account_unlink",
"open_pr_comment_workflow",
"github_comment_workflow",
"link_all_repos",
)
23 changes: 0 additions & 23 deletions src/sentry/integrations/github/tasks/open_pr_comment.py

This file was deleted.

11 changes: 1 addition & 10 deletions src/sentry/integrations/github/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from sentry.integrations.services.integration.model import RpcIntegration
from sentry.integrations.services.integration.service import integration_service
from sentry.integrations.services.repository.service import repository_service
from sentry.integrations.source_code_management.commit_context import CommitContextIntegration
from sentry.integrations.source_code_management.webhook import SCMWebhook
from sentry.integrations.types import IntegrationProviderSlug
from sentry.integrations.utils.metrics import IntegrationWebhookEvent, IntegrationWebhookEventType
Expand Down Expand Up @@ -754,7 +753,7 @@ def _handle(

author.preload_users()
try:
pr, created = PullRequest.objects.update_or_create(
PullRequest.objects.update_or_create(
organization_id=organization.id,
repository_id=repo.id,
key=number,
Expand All @@ -767,14 +766,6 @@ def _handle(
},
)

installation = integration.get_installation(organization_id=organization.id)
if (
action == "opened"
and created
and isinstance(installation, CommitContextIntegration)
):
installation.queue_open_pr_comment_task_if_needed(pr=pr, organization=organization)

except IntegrityError:
pass

Expand Down
10 changes: 1 addition & 9 deletions src/sentry/integrations/gitlab/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
from sentry.integrations.base import IntegrationDomain
from sentry.integrations.services.integration import integration_service
from sentry.integrations.services.integration.model import RpcIntegration
from sentry.integrations.source_code_management.commit_context import CommitContextIntegration
from sentry.integrations.source_code_management.webhook import SCMWebhook
from sentry.integrations.types import IntegrationProviderSlug
from sentry.integrations.utils.metrics import IntegrationWebhookEvent, IntegrationWebhookEventType
from sentry.integrations.utils.scope import clear_tags_and_context
from sentry.models.commit import Commit
from sentry.models.commitauthor import CommitAuthor
from sentry.models.organization import Organization
from sentry.models.pullrequest import PullRequest
from sentry.models.repository import Repository
from sentry.organizations.services.organization import organization_service
Expand Down Expand Up @@ -158,7 +156,6 @@ def __call__(self, event: Mapping[str, Any], **kwargs):
author_email = last_commit["author"]["email"]
author_name = last_commit["author"]["name"]

action = event["object_attributes"].get("action")
except KeyError as e:
logger.info(
"gitlab.webhook.invalid-merge-data",
Expand All @@ -177,7 +174,7 @@ def __call__(self, event: Mapping[str, Any], **kwargs):

author.preload_users()
try:
pr, created = PullRequest.objects.update_or_create(
PullRequest.objects.update_or_create(
organization_id=organization.id,
repository_id=repo.id,
key=number,
Expand All @@ -190,11 +187,6 @@ def __call__(self, event: Mapping[str, Any], **kwargs):
},
)

installation = integration.get_installation(organization_id=organization.id)
if action == "open" and created and isinstance(installation, CommitContextIntegration):
org = Organization.objects.get_from_cache(id=organization.id)
installation.queue_open_pr_comment_task_if_needed(pr=pr, organization=org)

except IntegrityError:
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,36 +335,6 @@ def queue_pr_comment_task_if_needed(

pr_comment_workflow.queue_task(pr=pr, project_id=group_owner.project_id)

def queue_open_pr_comment_task_if_needed(
self, pr: PullRequest, organization: Organization
) -> None:
try:
open_pr_comment_workflow = self.get_open_pr_comment_workflow()
except NotImplementedError:
return

if not OrganizationOption.objects.get_value(
organization=organization,
key=open_pr_comment_workflow.organization_option_key,
default=True,
):
logger.info(
_open_pr_comment_log(
integration_name=self.integration_name, suffix="option_missing"
),
extra={"organization_id": organization.id},
)
return

metrics.incr(
OPEN_PR_METRICS_BASE.format(integration=self.integration_name, key="queue_task")
)
logger.info(
_open_pr_comment_log(integration_name=self.integration_name, suffix="queue_task"),
extra={"pr_id": pr.id},
)
open_pr_comment_workflow.queue_task(pr=pr)

def create_or_update_comment(
self,
repo: Repository,
Expand Down Expand Up @@ -630,11 +600,6 @@ def referrer(self) -> Referrer:
def referrer_id(self) -> str:
raise NotImplementedError

def queue_task(self, pr: PullRequest) -> None:
from sentry.integrations.source_code_management.tasks import open_pr_comment_workflow

open_pr_comment_workflow.delay(pr_id=pr.id)

@abstractmethod
def get_pr_files_safe_for_comment(
self, repo: Repository, pr: PullRequest
Expand Down
Loading
Loading