Skip to content

Commit

Permalink
chore(github-growth): stop writing to commitfilechange language column (
Browse files Browse the repository at this point in the history
  • Loading branch information
cathteng authored Sep 20, 2023
1 parent c2959db commit 65e5743
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
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

0 comments on commit 65e5743

Please sign in to comment.