Loading
Add CITATION.cff detection and repository overview support
What does this MR do and why?
Adds minimal CITATION.cff support for software repositories (iteration 1).
- Detects
CITATION.cffas a special file type viaGitlab::FileDetector. - Exposes it through
Repository#citation_blobwith caching and cache invalidation. - Renders it with a new
BlobViewer::Citationauxiliary viewer and header partial. - Surfaces view/add actions on the project overview via
ProjectPresenter#citation_anchor_data.
Parsing citation metadata into APA/BibTeX strings remains a follow-up and will need the CFF gem plus docs.
References
- #337368
- !191467 (closed) (closed draft, prior attempt)
- https://gitlab.com/sdruskat/citation-support-for-gitlab (tracking repo)
Screenshots or screen recordings
The UI change is covered by a feature spec (spec/features/projects/show/user_sees_citation_button_spec.rb) that runs as a system test against the rendered pages, so both changes are asserted end-to-end.
| Before | After |
|---|---|
No CITATION.cff button in the Project information panel |
CITATION.cff button linking to the file, or Add CITATION.cff when the file is missing |
| Blob page shows only the raw file contents | Blob page shows a citation header with a "Learn more about CITATION.cff files." link above the file |
The actual screenshots are queued behind my fork's CI minutes quota and will be attached here as soon as they are generated.
How to set up and validate locally
- Add a
CITATION.cfffile to a test project on default branch. - Visit project overview, confirm
CITATION.cffbutton links to the blob page. - Visit the
CITATION.cffblob page, confirm auxiliary header renders with Learn more link. - Remove the file as a user with push access, confirm
Add CITATION.cffbutton appears. - Run focused specs:
bin/rspec spec/lib/gitlab/file_detector_spec.rbbin/rspec spec/models/blob_viewer/citation_spec.rbbin/rspec spec/models/repository_spec.rb -e '#citation_blob'bin/rspec spec/presenters/project_presenter_spec.rb -e '#citation_anchor_data'
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.
- Changelog trailer (
Changelog: added) on first commit - Tests added for file detection, repository cache, viewer, presenter
- Documentation update (follow-up with APA/BibTeX rendering)
- Screenshots attached (pending CI quota)
-
tooling/bin/gettext_extractor locale/gitlab.pot(verified bystatic-analysis 2/2job, which runsgettext:updated_check)
Edited by rajasekhar