Skip to content

Commit af77aff

Browse files
committed
adjust suspect commit time threshold
1 parent aa8a219 commit af77aff

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/sentry/integrations/utils/commit_context.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ def find_commit_context_for_event_all_frames(
7979
)
8080

8181
most_recent_blame = max(file_blames, key=lambda blame: blame.commit.committedDate, default=None)
82-
# Only return suspect commits that are less than a year old
82+
# Only return suspect commits that are less than 2 months old
8383
selected_blame = (
8484
most_recent_blame
85-
if most_recent_blame and is_date_less_than_year(most_recent_blame.commit.committedDate)
85+
if most_recent_blame
86+
and is_date_less_than_two_months(most_recent_blame.commit.committedDate)
8687
else None
8788
)
8889

@@ -109,8 +110,8 @@ def find_commit_context_for_event_all_frames(
109110
return (selected_blame, selected_install)
110111

111112

112-
def is_date_less_than_year(date: datetime) -> bool:
113-
return date > datetime.now(tz=timezone.utc) - timedelta(days=365)
113+
def is_date_less_than_two_months(date: datetime) -> bool:
114+
return date > datetime.now(tz=timezone.utc) - timedelta(days=60)
114115

115116

116117
def get_or_create_commit_from_blame(

tests/sentry/tasks/test_commit_context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def setUp(self) -> None:
132132
lineno=30,
133133
commit=CommitInfo(
134134
commitId="commit-id-old",
135-
committedDate=datetime.now(tz=datetime_timezone.utc) - timedelta(days=370),
135+
committedDate=datetime.now(tz=datetime_timezone.utc) - timedelta(days=62),
136136
commitMessage="old commit message",
137137
commitAuthorName=None,
138138
commitAuthorEmail="old@localhost",
@@ -668,7 +668,7 @@ def test_failure_old_blame(
668668
self, mock_get_commit_context, mock_record, mock_process_suspect_commits, mock_logger_info
669669
):
670670
"""
671-
A simple failure case where no blames are returned. We bail out and fall back
671+
A failure case where the only blame returned is past the time threshold. We bail out and fall back
672672
to the release-based suspect commits.
673673
"""
674674
mock_get_commit_context.return_value = [self.blame_too_old]

0 commit comments

Comments
 (0)