[6.4] 500 error when testing hook on empty repo
Created by: chulkilee
Processing by Projects::HooksController#test as HTML
Parameters: {"project_id"=>"groupname/reponame", "id"=>"1"}
Completed 500 Internal Server Error in 36ms
NoMethodError (undefined method `id' for nil:NilClass):
app/services/git_push_service.rb:62:in `sample_data'
app/contexts/test_hook_context.rb:4:in `execute'
app/controllers/projects/hooks_controller.rb:27:in `test'
app/controllers/application_controller.rb:57:in `set_current_user_for_thread'
The nil error happens because it tries to retrieve last and first commit from the repo, which do not exist. See https://github.com/gitlabhq/gitlabhq/blob/6-4-stable/app/services/git_push_service.rb#L62
Possible solution: disable test hook button when repo is empty