Promote `find_branch!` helper in the API
In lib/api/branches.rb
we have a find_branch!
helper:
def find_branch!(branch_name)
begin
user_project.repository.find_branch(branch_name) || not_found!('Branch')
rescue Gitlab::Git::CommandError
render_api_error!('The branch refname is invalid', 400)
end
end
However in lib/api/commits.rb
we're doing this instead (and in a number of places):
branch = user_project.repository.find_branch(params[:branch])
not_found!('Branch') unless branch
We should use the same way to find the branch.