prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Auto assign should occur as actor
  When using 'Fixes XXX' annotation in a commit, I noticed that while Sentry auto assigned to me (expected), it did so on behalf of itself instead of my user.
  
  ![screen shot 2017-08-28 at 9 16 42 am](https://user-images.githubusercontent.com/23610/29782513-b87a5cc0-8bd1-11e7-9fb1-0068f96a0df5.png)
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/sentry/receivers/releases.py`
  Content:
  ```
  1 from __future__ import absolute_import, print_function
  2 
  3 from django.db import IntegrityError, transaction
  4 from django.db.models.signals import post_save
  5 
  6 from sentry.models import (
  7     Activity, Commit, GroupAssignee, GroupCommitResolution, Release, TagValue
  8 )
  9 from sentry.tasks.clear_expired_resolutions import clear_expired_resolutions
  10 
  11 
  12 def ensure_release_exists(instance, created, **kwargs):
  13     if instance.key != 'sentry:release':
  14         return
  15 
  16     if instance.data and instance.data.get('release_id'):
  17         return
  18 
  19     try:
  20         with transaction.atomic():
  21             release = Release.objects.create(
  22                 organization_id=instance.project.organization_id,
  23                 version=instance.value,
  24                 date_added=instance.first_seen,
  25             )
  26     except IntegrityError:
  27         release = Release.objects.get(
  28             organization_id=instance.project.organization_id,
  29             version=instance.value,
  30         )
  31         release.update(date_added=instance.first_seen)
  32     else:
  33         instance.update(data={'release_id': release.id})
  34 
  35     release.add_project(instance.project)
  36 
  37 
  38 def resolve_group_resolutions(instance, created, **kwargs):
  39     if not created:
  40         return
  41 
  42     clear_expired_resolutions.delay(release_id=instance.id)
  43 
  44 
  45 def resolved_in_commit(instance, created, **kwargs):
  46     # TODO(dcramer): we probably should support an updated message
  47     if not created:
  48         return
  49 
  50     groups = instance.find_referenced_groups()
  51     for group in groups:
  52         try:
  53             with transaction.atomic():
  54                 GroupCommitResolution.objects.create(
  55                     group_id=group.id,
  56                     commit_id=instance.id,
  57                 )
  58                 if instance.author:
  59                     user_list = list(instance.author.find_users())
  60                 else:
  61                     user_list = ()
  62                 if user_list:
  63                     Activity.objects.create(
  64                         project_id=group.project_id,
  65                         group=group,
  66                         type=Activity.SET_RESOLVED_IN_COMMIT,
  67                         ident=instance.id,
  68                         user=user_list[0],
  69                         data={
  70                             'commit': instance.id,
  71                         }
  72                     )
  73                     GroupAssignee.objects.assign(group=group, assigned_to=user_list[0])
  74                 else:
  75                     Activity.objects.create(
  76                         project_id=group.project_id,
  77                         group=group,
  78                         type=Activity.SET_RESOLVED_IN_COMMIT,
  79                         ident=instance.id,
  80                         data={
  81                             'commit': instance.id,
  82                         }
  83                     )
  84         except IntegrityError:
  85             pass
  86 
  87 
  88 post_save.connect(
  89     resolve_group_resolutions, sender=Release, dispatch_uid="resolve_group_resolutions", weak=False
  90 )
  91 
  92 post_save.connect(
  93     ensure_release_exists, sender=TagValue, dispatch_uid="ensure_release_exists", weak=False
  94 )
  95 
  96 post_save.connect(
  97     resolved_in_commit,
  98     sender=Commit,
  99     dispatch_uid="resolved_in_commit",
  100     weak=False,
  101 )
  102
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/sentry/receivers/releases.py b/src/sentry/receivers/releases.py
  --- a/src/sentry/receivers/releases.py
  +++ b/src/sentry/receivers/releases.py
  @@ -70,7 +70,8 @@
                               'commit': instance.id,
                           }
                       )
  -                    GroupAssignee.objects.assign(group=group, assigned_to=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,
  
verification_info: {"golden_diff": "diff --git a/src/sentry/receivers/releases.py b/src/sentry/receivers/releases.py\n--- a/src/sentry/receivers/releases.py\n+++ b/src/sentry/receivers/releases.py\n@@ -70,7 +70,8 @@\n                             'commit': instance.id,\n                         }\n                     )\n-                    GroupAssignee.objects.assign(group=group, assigned_to=user_list[0])\n+                    GroupAssignee.objects.assign(\n+                        group=group, assigned_to=user_list[0], acting_user=user_list[0])\n                 else:\n                     Activity.objects.create(\n                         project_id=group.project_id,\n", "issue": "Auto assign should occur as actor\nWhen using 'Fixes XXX' annotation in a commit, I noticed that while Sentry auto assigned to me (expected), it did so on behalf of itself instead of my user.\r\n\r\n![screen shot 2017-08-28 at 9 16 42 am](https://user-images.githubusercontent.com/23610/29782513-b87a5cc0-8bd1-11e7-9fb1-0068f96a0df5.png)\r\n\n", "before_files": [{"content": "from __future__ import absolute_import, print_function\n\nfrom django.db import IntegrityError, transaction\nfrom django.db.models.signals import post_save\n\nfrom sentry.models import (\n    Activity, Commit, GroupAssignee, GroupCommitResolution, Release, TagValue\n)\nfrom sentry.tasks.clear_expired_resolutions import clear_expired_resolutions\n\n\ndef ensure_release_exists(instance, created, **kwargs):\n    if instance.key != 'sentry:release':\n        return\n\n    if instance.data and instance.data.get('release_id'):\n        return\n\n    try:\n        with transaction.atomic():\n            release = Release.objects.create(\n                organization_id=instance.project.organization_id,\n                version=instance.value,\n                date_added=instance.first_seen,\n            )\n    except IntegrityError:\n        release = Release.objects.get(\n            organization_id=instance.project.organization_id,\n            version=instance.value,\n        )\n        release.update(date_added=instance.first_seen)\n    else:\n        instance.update(data={'release_id': release.id})\n\n    release.add_project(instance.project)\n\n\ndef resolve_group_resolutions(instance, created, **kwargs):\n    if not created:\n        return\n\n    clear_expired_resolutions.delay(release_id=instance.id)\n\n\ndef resolved_in_commit(instance, created, **kwargs):\n    # TODO(dcramer): we probably should support an updated message\n    if not created:\n        return\n\n    groups = instance.find_referenced_groups()\n    for group in groups:\n        try:\n            with transaction.atomic():\n                GroupCommitResolution.objects.create(\n                    group_id=group.id,\n                    commit_id=instance.id,\n                )\n                if instance.author:\n                    user_list = list(instance.author.find_users())\n                else:\n                    user_list = ()\n                if user_list:\n                    Activity.objects.create(\n                        project_id=group.project_id,\n                        group=group,\n                        type=Activity.SET_RESOLVED_IN_COMMIT,\n                        ident=instance.id,\n                        user=user_list[0],\n                        data={\n                            'commit': instance.id,\n                        }\n                    )\n                    GroupAssignee.objects.assign(group=group, assigned_to=user_list[0])\n                else:\n                    Activity.objects.create(\n                        project_id=group.project_id,\n                        group=group,\n                        type=Activity.SET_RESOLVED_IN_COMMIT,\n                        ident=instance.id,\n                        data={\n                            'commit': instance.id,\n                        }\n                    )\n        except IntegrityError:\n            pass\n\n\npost_save.connect(\n    resolve_group_resolutions, sender=Release, dispatch_uid=\"resolve_group_resolutions\", weak=False\n)\n\npost_save.connect(\n    ensure_release_exists, sender=TagValue, dispatch_uid=\"ensure_release_exists\", weak=False\n)\n\npost_save.connect(\n    resolved_in_commit,\n    sender=Commit,\n    dispatch_uid=\"resolved_in_commit\",\n    weak=False,\n)\n", "path": "src/sentry/receivers/releases.py"}], "after_files": [{"content": "from __future__ import absolute_import, print_function\n\nfrom django.db import IntegrityError, transaction\nfrom django.db.models.signals import post_save\n\nfrom sentry.models import (\n    Activity, Commit, GroupAssignee, GroupCommitResolution, Release, TagValue\n)\nfrom sentry.tasks.clear_expired_resolutions import clear_expired_resolutions\n\n\ndef ensure_release_exists(instance, created, **kwargs):\n    if instance.key != 'sentry:release':\n        return\n\n    if instance.data and instance.data.get('release_id'):\n        return\n\n    try:\n        with transaction.atomic():\n            release = Release.objects.create(\n                organization_id=instance.project.organization_id,\n                version=instance.value,\n                date_added=instance.first_seen,\n            )\n    except IntegrityError:\n        release = Release.objects.get(\n            organization_id=instance.project.organization_id,\n            version=instance.value,\n        )\n        release.update(date_added=instance.first_seen)\n    else:\n        instance.update(data={'release_id': release.id})\n\n    release.add_project(instance.project)\n\n\ndef resolve_group_resolutions(instance, created, **kwargs):\n    if not created:\n        return\n\n    clear_expired_resolutions.delay(release_id=instance.id)\n\n\ndef resolved_in_commit(instance, created, **kwargs):\n    # TODO(dcramer): we probably should support an updated message\n    if not created:\n        return\n\n    groups = instance.find_referenced_groups()\n    for group in groups:\n        try:\n            with transaction.atomic():\n                GroupCommitResolution.objects.create(\n                    group_id=group.id,\n                    commit_id=instance.id,\n                )\n                if instance.author:\n                    user_list = list(instance.author.find_users())\n                else:\n                    user_list = ()\n                if user_list:\n                    Activity.objects.create(\n                        project_id=group.project_id,\n                        group=group,\n                        type=Activity.SET_RESOLVED_IN_COMMIT,\n                        ident=instance.id,\n                        user=user_list[0],\n                        data={\n                            'commit': instance.id,\n                        }\n                    )\n                    GroupAssignee.objects.assign(\n                        group=group, assigned_to=user_list[0], acting_user=user_list[0])\n                else:\n                    Activity.objects.create(\n                        project_id=group.project_id,\n                        group=group,\n                        type=Activity.SET_RESOLVED_IN_COMMIT,\n                        ident=instance.id,\n                        data={\n                            'commit': instance.id,\n                        }\n                    )\n        except IntegrityError:\n            pass\n\n\npost_save.connect(\n    resolve_group_resolutions, sender=Release, dispatch_uid=\"resolve_group_resolutions\", weak=False\n)\n\npost_save.connect(\n    ensure_release_exists, sender=TagValue, dispatch_uid=\"ensure_release_exists\", weak=False\n)\n\npost_save.connect(\n    resolved_in_commit,\n    sender=Commit,\n    dispatch_uid=\"resolved_in_commit\",\n    weak=False,\n)\n", "path": "src/sentry/receivers/releases.py"}]}