Context: #7000
The backend only supports "github" as a VCS provider. The upload serialiser doesn't even expose the vcs_provider field — it relies on the model default. The permalink generator raises NotImplementedError for anything else, and the feature-list annotation omits the provider entirely.
Scope
Accept, store, and serve GitLab code references with correct permalinks. Expose vcs_provider in the feature-list API so the frontend can show the right icon.
Changes
api/projects/code_references/types.py: Add GITLAB = "gitlab", "GitLab" to VCSProvider. Add vcs_provider: str to CodeReferencesRepositoryCount.
api/projects/code_references/services.py: Add a VCSProvider.GITLAB case to _get_permalink(). GitLab's file permalink format uses /-/blob/: {repo_url}/-/blob/{revision}/{file_path}#L{line_number}. Also add vcs_provider=F("vcs_provider") to the JSONObject in annotate_feature_queryset_with_code_references_summary().
api/projects/code_references/serializers.py: Expose "vcs_provider" in the upload serialiser's fields. Add vcs_provider to the count serialiser.
api/projects/code_references/models.py: Keep default=VCSProvider.GITHUB for backward compatibility — existing CI clients don't send the field.
Migration: Auto-generate with make docker-up django-make-migrations.
Tests
Services: permalink generation for GitLab URLs (public and self-hosted, with and without trailing slash).
Views: upload with vcs_provider: "gitlab" returns 201; upload with invalid provider returns 400; detail view for a GitLab scan returns /-/blob/ permalinks.
Features views: existing code_references_counts test asserts vcs_provider is present.
Acceptance criteria
Context: #7000
The backend only supports
"github"as a VCS provider. The upload serialiser doesn't even expose thevcs_providerfield — it relies on the model default. The permalink generator raisesNotImplementedErrorfor anything else, and the feature-list annotation omits the provider entirely.Scope
Accept, store, and serve GitLab code references with correct permalinks. Expose
vcs_providerin the feature-list API so the frontend can show the right icon.Changes
api/projects/code_references/types.py: AddGITLAB = "gitlab", "GitLab"toVCSProvider. Addvcs_provider: strtoCodeReferencesRepositoryCount.api/projects/code_references/services.py: Add aVCSProvider.GITLABcase to_get_permalink(). GitLab's file permalink format uses/-/blob/:{repo_url}/-/blob/{revision}/{file_path}#L{line_number}. Also addvcs_provider=F("vcs_provider")to theJSONObjectinannotate_feature_queryset_with_code_references_summary().api/projects/code_references/serializers.py: Expose"vcs_provider"in the upload serialiser'sfields. Addvcs_providerto the count serialiser.api/projects/code_references/models.py: Keepdefault=VCSProvider.GITHUBfor backward compatibility — existing CI clients don't send the field.Migration: Auto-generate with
make docker-up django-make-migrations.Tests
Services: permalink generation for GitLab URLs (public and self-hosted, with and without trailing slash).
Views: upload with
vcs_provider: "gitlab"returns 201; upload with invalid provider returns 400; detail view for a GitLab scan returns/-/blob/permalinks.Features views: existing
code_references_countstest assertsvcs_provideris present.Acceptance criteria
POST .../code-references/acceptsvcs_provider: "gitlab"vcs_providerdefaults to"github"/-/blob/formatvcs_providerincode_references_countsmake lint && make typecheckpass