-
Notifications
You must be signed in to change notification settings - Fork 45
Backend support for github provider #3252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
37140cc
Update Revision and Diff to support a generic provider
vrigal c0c3148
Updates related to Revision provider
vrigal e08b79e
Only rely on Diff provider ID
vrigal 3f7069a
Build an usable slug for Github repositories
vrigal 0db79aa
Update tests
vrigal f546369
Use a + to slugify github repositories
vrigal e9a0b87
Fix slug assertion for new repository
Archaeopteryx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
backend/code_review_backend/issues/migrations/0016_revision_diff_generic_provider.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Generated by Django 5.1.6 on 2026-01-21 16:01 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("issues", "0015_remove_repository_phid_alter_repository_id"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterModelOptions( | ||
| name="revision", | ||
| options={"ordering": ("provider", "provider_id", "id")}, | ||
| ), | ||
| migrations.RemoveConstraint( | ||
| model_name="revision", | ||
| name="revision_unique_phab_id", | ||
| ), | ||
| migrations.RenameField( | ||
| model_name="revision", | ||
| old_name="phabricator_id", | ||
| new_name="provider_id", | ||
| ), | ||
| migrations.AddField( | ||
| model_name="revision", | ||
| name="provider", | ||
| field=models.CharField( | ||
| choices=[("phabricator", "Phabricator"), ("github", "Github")], | ||
| default="phabricator", | ||
| max_length=20, | ||
| ), | ||
| ), | ||
| migrations.AddConstraint( | ||
| model_name="revision", | ||
| constraint=models.UniqueConstraint( | ||
| condition=models.Q(("provider_id__isnull", False)), | ||
| fields=("provider_id",), | ||
| name="revision_unique_phab_id", | ||
| ), | ||
| ), | ||
| migrations.RemoveConstraint( | ||
| model_name="revision", | ||
| name="revision_unique_phab_phabid", | ||
| ), | ||
| migrations.RemoveField( | ||
| model_name="revision", | ||
| name="phabricator_phid", | ||
| ), | ||
| migrations.RenameField( | ||
| model_name="diff", | ||
| old_name="phid", | ||
| new_name="provider_id", | ||
| ), | ||
| ] |
67 changes: 67 additions & 0 deletions
67
backend/code_review_backend/issues/migrations/0017_diff_auto_pk.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # This Source Code Form is subject to the terms of the Mozilla Public | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
|
||
| from django.db import migrations, models | ||
| from django.db.models import F | ||
|
|
||
|
|
||
| def _update_provider_id(apps, schema_editor): | ||
| """ | ||
| Update all diffs, setting the current ID as the provider ID. | ||
| This step is required no to loose the Phabricator integer ID, | ||
| which is the reference used by most developers. | ||
| The previous value (PHID-DIFF-xxxxxxxxxxxxxxxxxxxx) is dropped, | ||
| then the PK is replaced by a random UUID, allowing the support | ||
| of other providers without a known unique integer identifier. | ||
| """ | ||
| Diff = apps.get_model("issues", "Diff") | ||
| Diff.objects.update(provider_id=F("id")) | ||
|
|
||
|
|
||
| def _reset_postgres_sequense(apps, schema_editor): | ||
| """ | ||
| PostgreSQL needs to update the auto increment sequence value, otherwise | ||
| conflicts would happen when we reach the initial Diff ID. | ||
|
|
||
| This command was initially generated with ./manage.py sqlsequencereset issues | ||
| """ | ||
| if schema_editor.connection.vendor != "postgresql": | ||
| # The SQLite backend automatically handles the auto increment update | ||
| return | ||
| schema_editor.execute( | ||
| """SELECT setval( | ||
| pg_get_serial_sequence('"issues_diff"','id'), | ||
| coalesce(max("id"), 1), | ||
| max("id") IS NOT null | ||
| ) FROM "issues_diff"; | ||
| """, | ||
| ) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("issues", "0016_revision_diff_generic_provider"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| # Save the Phabricator integer ID in Diff.provider_id | ||
| migrations.RunPython( | ||
| _update_provider_id, | ||
| reverse_code=migrations.RunPython.noop, | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="diff", | ||
| name="id", | ||
| field=models.AutoField(primary_key=True, serialize=False), | ||
| ), | ||
| migrations.AlterModelOptions( | ||
| name="diff", | ||
| options={"ordering": ("created",)}, | ||
| ), | ||
| # Restore the sequence with PostgreSQL backend | ||
| migrations.RunPython( | ||
| _reset_postgres_sequense, | ||
| reverse_code=migrations.RunPython.noop, | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.