Fix 500 error for Commits API
What does this MR do and why?
Contributes to #360312 (closed)
Problem
We skip the check for the branch name when the repository is empty.
Solution
Verify the branch name for the empty repository case too.
Screenshots or screen recordings
1) API::Commits POST /projects/:id/repository/commits create when repository is empty and branch name is invalid behaves like successfully creates the commit creates the commit
Failure/Error: expect(response).to have_gitlab_http_status(:created)
expected the response to have status code :created but it was 500. The response was: {"message":"\nGRPC::InvalidArgument (3:TreeEntry: revision can't contain ':'.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.