Skip to content

Use root_ref to get last commit for index integrity

What does this MR do and why?

Related to #419405 (closed)

project.commit is using this method through HasRepository). The commit method defaults to HEAD if no ref is provided and that causes problems when HEAD points to a non-existent branch. (see #419405 (comment 1481780993) for an example from rails console)

This MR makes two changes for index repair:

  1. Use the default branch when asking for the latest commit for a project
  2. Check that the commit is not null

Screenshots or screen recordings

N/A

How to set up and validate locally

I'm not sure how to get a repository with a HEAD referencing a branch that does not exist. the steps that I used in !122912 (merged) aren't working locally anymore. I'm confident in this fix.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Terri Chu

Merge request reports