Remove Repository#root_ref_sha method
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem
Bug in NoMethodError: undefined method `sha' for nil:N... (#395480 - closed) exposes the problem with Repository#root_ref_sha method
It doesn't verify that the head commit exist and it leads to NoMethodError.
This method is used across the application.
Proposal
Remove the method completely and replace usages with the code that correctly handles this case.
head_commit = repository.head_commit
if head_commit
sha = head_commit.sha
...
Or alternatively, use head_commit&.sha version. However, we should still verify that it doesn't break existing code.
Edited by 🤖 GitLab Bot 🤖