Draft: Fall back to the pipeline SHA when the commit is not readable
What does this MR do and why?
Related to #627161 (closed) (the "Can't find HEAD commit for this branch" half; the Cancel/Retry half shipped in !253244 (merged)).
Since the pipelines list moved to GraphQL in 18.10, Guests on private projects see "Can't find HEAD commit for this branch" and an empty commit chip on every row of Build > Pipelines, and no SHA in the pipeline details header. The commit exists. What's missing is permission: the list selects Pipeline.commit, typed as Commit, and Commit is authorized on read_code. Guests have read_pipeline but not read_code, so the field is silently null, and pipeline_url.vue treats a null commit as "no HEAD commit". The pre-18.10 REST list exposed the commit summary through Ci::PipelineEntity without a permission check, which is why Guests used to see it.
This MR is the quick fix so the page stops looking broken: it reads the SHA and commit link from two Pipeline fields that only need read_pipeline and already exist, sha and commitPath. No schema change.
pipeline_list_item_base.fragment.graphqlandget_pipeline_header_data.query.graphqlselectshaandcommitPath.pipeline_url.vuefalls back to them for the commit chip, and only shows "Can't find HEAD commit for this branch" when there is no SHA at all (the orphaned ref case the message was written for). The commit popover and author avatar still needcommit.pipeline_header.vuefalls back to them for the "For commit" link and the copy button.
Guests still don't get the commit title or author. Restoring those needs new read_pipeline-gated fields on Pipeline; I'm doing that in a follow-up MR pair (backend first). The commit link itself keeps 404ing for Guests because the commit page requires read_code; that matches the REST-era page.
Screenshots or screen recordings
| Before | After | |
|---|---|---|
| Guest, Build > Pipelines | ||
| Guest, pipeline header |
How to set up and validate locally
- Create a private project with a repository and at least one pipeline. Keep Settings > CI/CD > General pipelines > Project-based pipeline visibility enabled.
- Add a user as Guest, sign in as that user.
- Open Build > Pipelines. On
master: every row says "Can't find HEAD commit for this branch" and the commit chip is empty. On this branch: no message, the chip shows the short SHA linking to the commit. - Open any pipeline. On
masterthe header's "For commit" line has no SHA. On this branch it shows the short SHA link and the copy button copies the full SHA. - Repeat as a Reporter: unchanged, commit title, popover and avatar still render.
To confirm the cause from the console:
project = Project.find_by_full_path('group/project')
guest = User.find_by(username: 'guest')
Ability.allowed?(guest, :read_pipeline, project) # => true
Ability.allowed?(guest, :read_code, project) # => falseMR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.