55import re
66from collections .abc import Mapping , Sequence
77from time import time
8- from typing import ClassVar
8+ from typing import ClassVar , TypedDict
99
1010import orjson
1111import sentry_sdk
3636from sentry .locks import locks
3737from sentry .models .activity import Activity
3838from sentry .models .artifactbundle import ArtifactBundle
39+ from sentry .models .commitauthor import CommitAuthor
3940from sentry .models .commitfilechange import CommitFileChange
4041from sentry .models .grouphistory import GroupHistoryStatus , record_group_history
4142from sentry .models .groupinbox import GroupInbox , GroupInboxRemoveAction , remove_group_from_inbox
@@ -178,6 +179,12 @@ def get_group_release_version(
178179 return release_version or None
179180
180181
182+ class _CommitDataKwargs (TypedDict , total = False ):
183+ author : CommitAuthor
184+ message : str
185+ date_added : str
186+
187+
181188@region_silo_model
182189class Release (Model ):
183190 """
@@ -658,7 +665,6 @@ def set_commits(self, commit_list):
658665
659666 # TODO(dcramer): this function could use some cleanup/refactoring as it's a bit unwieldy
660667 from sentry .models .commit import Commit
661- from sentry .models .commitauthor import CommitAuthor
662668 from sentry .models .group import Group , GroupStatus
663669 from sentry .models .grouplink import GroupLink
664670 from sentry .models .groupresolution import GroupResolution
@@ -752,7 +758,7 @@ def set_commits(self, commit_list):
752758 else :
753759 author = authors [author_email ]
754760
755- commit_data = {}
761+ commit_data : _CommitDataKwargs = {}
756762
757763 # Update/set message and author if they are provided.
758764 if author is not None :
@@ -768,14 +774,10 @@ def set_commits(self, commit_list):
768774 key = data ["id" ],
769775 defaults = commit_data ,
770776 )
771- if not created :
772- commit_data = {
773- key : value
774- for key , value in commit_data .items ()
775- if getattr (commit , key ) != value
776- }
777- if commit_data :
778- commit .update (** commit_data )
777+ if not created and any (
778+ getattr (commit , key ) != value for key , value in commit_data .items ()
779+ ):
780+ commit .update (** commit_data )
779781
780782 if author is None :
781783 author = commit .author
0 commit comments