Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(github-growth): stop writing to commitfilechange language column #56491

Merged
Merged
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
20 changes: 1 addition & 19 deletions src/sentry/integrations/github/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sentry import analytics, features, options
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import Endpoint, region_silo_endpoint
from sentry.constants import EXTENSION_LANGUAGE_MAP, ObjectStatus
from sentry.constants import ObjectStatus
from sentry.integrations.utils.scope import clear_tags_and_context
from sentry.models import Commit, CommitAuthor, Organization, PullRequest, Repository
from sentry.models.commitfilechange import CommitFileChange
Expand Down Expand Up @@ -47,18 +47,6 @@ def get_github_external_id(event: Mapping[str, Any], host: str | None = None) ->
return f"{host}:{external_id}" if host else external_id


def get_file_language(filename: str):
extension = filename.split(".")[-1]
language = None
if extension != filename:
language = EXTENSION_LANGUAGE_MAP.get(extension)

if language is None:
logger.info("github.unaccounted_file_lang", extra={"extension": extension})

return language


class Webhook:
provider = "github"

Expand Down Expand Up @@ -369,31 +357,25 @@ def _handle(
date_added=parse_date(commit["timestamp"]).astimezone(timezone.utc),
)
for fname in commit["added"]:
language = get_file_language(fname)
CommitFileChange.objects.create(
organization_id=organization.id,
commit=c,
filename=fname,
type="A",
language=language,
)
for fname in commit["removed"]:
language = get_file_language(fname)
CommitFileChange.objects.create(
organization_id=organization.id,
commit=c,
filename=fname,
type="D",
language=language,
)
for fname in commit["modified"]:
language = get_file_language(fname)
CommitFileChange.objects.create(
organization_id=organization.id,
commit=c,
filename=fname,
type="M",
language=language,
)
except IntegrityError:
pass
Expand Down
4 changes: 0 additions & 4 deletions tests/sentry/integrations/github/test_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ def test_simple(self):

commit_filechanges = CommitFileChange.objects.all()
assert len(commit_filechanges) == 2
assert commit_filechanges[0].language == "python"
assert commit_filechanges[1].language is None

def test_auto_linking_missing_feature_flag(self):
project = self.project # force creation
Expand Down Expand Up @@ -221,8 +219,6 @@ def test_anonymous_lookup(self):

commit_filechanges = CommitFileChange.objects.all()
assert len(commit_filechanges) == 2
assert commit_filechanges[0].language == "python"
assert commit_filechanges[1].language is None

def test_multiple_orgs(self):
project = self.project # force creation
Expand Down
Loading