prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  0077_move_remote_url_credentials.py fails on Remotes that have @ in path, not netloc
  **Version**
  3.18.10
  
  **Describe the bug**
  Migration 0077 fails when you have a remote that has an @ somewhere in the path
  
  ```
    Applying core.0077_move_remote_url_credentials...Traceback (most recent call last):
    File "/usr/bin/pulpcore-manager", line 33, in <module>
      sys.exit(load_entry_point('pulpcore==3.18.10', 'console_scripts', 'pulpcore-manager')())
    File "/usr/lib/python3.9/site-packages/pulpcore/app/manage.py", line 11, in manage
      execute_from_command_line(sys.argv)
    File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
      utility.execute()
    File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
      self.execute(*args, **cmd_options)
    File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
      output = self.handle(*args, **options)
    File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 89, in wrapped
      res = handle_func(*args, **kwargs)
    File "/usr/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 244, in handle
      post_migrate_state = executor.migrate(
    File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate
      state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
    File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
      state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
    File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
      state = migration.apply(state, schema_editor)
    File "/usr/lib/python3.9/site-packages/django/db/migrations/migration.py", line 126, in apply
      operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
    File "/usr/lib/python3.9/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
      self.code(from_state.apps, schema_editor)
    File "/usr/lib/python3.9/site-packages/pulpcore/app/migrations/0077_move_remote_url_credentials.py", line 19, in move_remote_url_credentials
      _, url_split = url.netloc.rsplit("@", maxsplit=1)
  ValueError: not enough values to unpack (expected 2, got 1)
  ```
  
  **To Reproduce**
  Steps to reproduce the behavior:
  * Have a remote `https://download.copr.fedorainfracloud.org/results/@caddy/caddy/epel-8-x86_64/`
  * Try to migrate 0077
  
  **Expected behavior**
  migration aplies
  
  **Additional context**
  https://community.theforeman.org/t/foreman-3-3-katello-4-5-upgrade-failed-pulpcore-manager-migrate-noinput/31088
  
  
  </issue>
  <code>
  [start of pulpcore/app/migrations/0077_move_remote_url_credentials.py]
  1 # Generated by Django 3.2.6 on 2021-09-29 14:00
  2 
  3 from urllib.parse import urlparse, urlunparse
  4 
  5 from django.db import migrations
  6 
  7 
  8 def move_remote_url_credentials(apps, schema_editor):
  9     Remote = apps.get_model("core", "Remote")
  10 
  11     for remote in Remote.objects.filter(url__contains="@").iterator():
  12         url = urlparse(remote.url)
  13 
  14         if not remote.username:
  15             remote.username = url.username
  16         if not remote.password:
  17             remote.password = url.password
  18 
  19         _, url_split = url.netloc.rsplit("@", maxsplit=1)
  20         remote.url = urlunparse(url._replace(netloc=url_split))
  21         remote.save()
  22 
  23 
  24 class Migration(migrations.Migration):
  25 
  26     dependencies = [
  27         ('core', '0076_remove_reserved_resource'),
  28     ]
  29 
  30     operations = [
  31         migrations.RunPython(
  32             code=move_remote_url_credentials,
  33             reverse_code=migrations.RunPython.noop,
  34             elidable=True,
  35         )
  36     ]
  37
  [end of pulpcore/app/migrations/0077_move_remote_url_credentials.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pulpcore/app/migrations/0077_move_remote_url_credentials.py b/pulpcore/app/migrations/0077_move_remote_url_credentials.py
  --- a/pulpcore/app/migrations/0077_move_remote_url_credentials.py
  +++ b/pulpcore/app/migrations/0077_move_remote_url_credentials.py
  @@ -11,6 +11,11 @@
       for remote in Remote.objects.filter(url__contains="@").iterator():
           url = urlparse(remote.url)
   
  +        if '@' not in url.netloc:
  +            # URLs can have an @ in other places than the netloc,
  +            # but those do not indicate credentials
  +            continue
  +
           if not remote.username:
               remote.username = url.username
           if not remote.password:
  
verification_info: {"golden_diff": "diff --git a/pulpcore/app/migrations/0077_move_remote_url_credentials.py b/pulpcore/app/migrations/0077_move_remote_url_credentials.py\n--- a/pulpcore/app/migrations/0077_move_remote_url_credentials.py\n+++ b/pulpcore/app/migrations/0077_move_remote_url_credentials.py\n@@ -11,6 +11,11 @@\n     for remote in Remote.objects.filter(url__contains=\"@\").iterator():\n         url = urlparse(remote.url)\n \n+        if '@' not in url.netloc:\n+            # URLs can have an @ in other places than the netloc,\n+            # but those do not indicate credentials\n+            continue\n+\n         if not remote.username:\n             remote.username = url.username\n         if not remote.password:\n", "issue": "0077_move_remote_url_credentials.py fails on Remotes that have @ in path, not netloc\n**Version**\r\n3.18.10\r\n\r\n**Describe the bug**\r\nMigration 0077 fails when you have a remote that has an @ somewhere in the path\r\n\r\n```\r\n  Applying core.0077_move_remote_url_credentials...Traceback (most recent call last):\r\n  File \"/usr/bin/pulpcore-manager\", line 33, in <module>\r\n    sys.exit(load_entry_point('pulpcore==3.18.10', 'console_scripts', 'pulpcore-manager')())\r\n  File \"/usr/lib/python3.9/site-packages/pulpcore/app/manage.py\", line 11, in manage\r\n    execute_from_command_line(sys.argv)\r\n  File \"/usr/lib/python3.9/site-packages/django/core/management/__init__.py\", line 419, in execute_from_command_line\r\n    utility.execute()\r\n  File \"/usr/lib/python3.9/site-packages/django/core/management/__init__.py\", line 413, in execute\r\n    self.fetch_command(subcommand).run_from_argv(self.argv)\r\n  File \"/usr/lib/python3.9/site-packages/django/core/management/base.py\", line 354, in run_from_argv\r\n    self.execute(*args, **cmd_options)\r\n  File \"/usr/lib/python3.9/site-packages/django/core/management/base.py\", line 398, in execute\r\n    output = self.handle(*args, **options)\r\n  File \"/usr/lib/python3.9/site-packages/django/core/management/base.py\", line 89, in wrapped\r\n    res = handle_func(*args, **kwargs)\r\n  File \"/usr/lib/python3.9/site-packages/django/core/management/commands/migrate.py\", line 244, in handle\r\n    post_migrate_state = executor.migrate(\r\n  File \"/usr/lib/python3.9/site-packages/django/db/migrations/executor.py\", line 117, in migrate\r\n    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)\r\n  File \"/usr/lib/python3.9/site-packages/django/db/migrations/executor.py\", line 147, in _migrate_all_forwards\r\n    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)\r\n  File \"/usr/lib/python3.9/site-packages/django/db/migrations/executor.py\", line 227, in apply_migration\r\n    state = migration.apply(state, schema_editor)\r\n  File \"/usr/lib/python3.9/site-packages/django/db/migrations/migration.py\", line 126, in apply\r\n    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)\r\n  File \"/usr/lib/python3.9/site-packages/django/db/migrations/operations/special.py\", line 190, in database_forwards\r\n    self.code(from_state.apps, schema_editor)\r\n  File \"/usr/lib/python3.9/site-packages/pulpcore/app/migrations/0077_move_remote_url_credentials.py\", line 19, in move_remote_url_credentials\r\n    _, url_split = url.netloc.rsplit(\"@\", maxsplit=1)\r\nValueError: not enough values to unpack (expected 2, got 1)\r\n```\r\n\r\n**To Reproduce**\r\nSteps to reproduce the behavior:\r\n* Have a remote `https://download.copr.fedorainfracloud.org/results/@caddy/caddy/epel-8-x86_64/`\r\n* Try to migrate 0077\r\n\r\n**Expected behavior**\r\nmigration aplies\r\n\r\n**Additional context**\r\nhttps://community.theforeman.org/t/foreman-3-3-katello-4-5-upgrade-failed-pulpcore-manager-migrate-noinput/31088\r\n\n", "before_files": [{"content": "# Generated by Django 3.2.6 on 2021-09-29 14:00\n\nfrom urllib.parse import urlparse, urlunparse\n\nfrom django.db import migrations\n\n\ndef move_remote_url_credentials(apps, schema_editor):\n    Remote = apps.get_model(\"core\", \"Remote\")\n\n    for remote in Remote.objects.filter(url__contains=\"@\").iterator():\n        url = urlparse(remote.url)\n\n        if not remote.username:\n            remote.username = url.username\n        if not remote.password:\n            remote.password = url.password\n\n        _, url_split = url.netloc.rsplit(\"@\", maxsplit=1)\n        remote.url = urlunparse(url._replace(netloc=url_split))\n        remote.save()\n\n\nclass Migration(migrations.Migration):\n\n    dependencies = [\n        ('core', '0076_remove_reserved_resource'),\n    ]\n\n    operations = [\n        migrations.RunPython(\n            code=move_remote_url_credentials,\n            reverse_code=migrations.RunPython.noop,\n            elidable=True,\n        )\n    ]\n", "path": "pulpcore/app/migrations/0077_move_remote_url_credentials.py"}]}