Skip to content
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
36 changes: 15 additions & 21 deletions src/sentry/receivers/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,30 +189,24 @@ def resolved_in_pull_request(instance, created, **kwargs):
user_list = list(instance.author.find_users())
else:
user_list = ()
acting_user = None
if user_list:
Activity.objects.create(
project_id=group.project_id,
group=group,
type=Activity.SET_RESOLVED_IN_PULL_REQUEST,
ident=instance.id,
user=user_list[0],
data={"pull_request": instance.id},
)
record_group_history(
group, GroupHistoryStatus.RESOLVED_IN_PULL_REQUEST, actor=user_list[0]
)

acting_user = user_list[0]
GroupAssignee.objects.assign(
group=group, assigned_to=user_list[0], acting_user=user_list[0]
)
else:
Activity.objects.create(
project_id=group.project_id,
group=group,
type=Activity.SET_RESOLVED_IN_PULL_REQUEST,
ident=instance.id,
data={"pull_request": instance.id},
group=group, assigned_to=acting_user, acting_user=acting_user
)

Activity.objects.create(
project_id=group.project_id,
group=group,
type=Activity.SET_RESOLVED_IN_PULL_REQUEST,
ident=instance.id,
user=acting_user,
data={"pull_request": instance.id},
)
record_group_history(
group, GroupHistoryStatus.SET_RESOLVED_IN_PULL_REQUEST, actor=acting_user
)
except IntegrityError:
pass
else:
Expand Down
21 changes: 13 additions & 8 deletions tests/sentry/models/test_pullrequest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from hashlib import sha1
from uuid import uuid4

from sentry.models import Commit, PullRequest, Repository
from sentry.models import Commit, GroupHistory, GroupHistoryStatus, PullRequest, Repository
from sentry.testutils import TestCase


Expand All @@ -23,14 +23,19 @@ def test_multiple_matches_basic(self):
assert len(groups) == 1
assert group in groups

pr = PullRequest.objects.create(
key="1",
repository_id=repo.id,
organization_id=group.organization.id,
title="very cool PR to fix the thing",
message=f"Foo Biz\n\nFixes {group2.qualified_short_id}",
)
with self.feature("organizations:group-history"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this flag removed in the other PR?

Copy link
Member Author

@wedamija wedamija Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I made all these prs in a separate order, I'll merge the other one first and update this I'll merge this first and update the feature removing one

pr = PullRequest.objects.create(
key="1",
repository_id=repo.id,
organization_id=group.organization.id,
title="very cool PR to fix the thing",
message=f"Foo Biz\n\nFixes {group2.qualified_short_id}",
)

groups = pr.find_referenced_groups()
assert len(groups) == 1
assert group2 in groups
assert GroupHistory.objects.filter(
group=group2,
status=GroupHistoryStatus.SET_RESOLVED_IN_PULL_REQUEST,
)