'Test settings' button for services gives 500 on empty repo

Created by: zedtux

While I was using the "Test settings" button from the HipChat service for a project without commit I got the following 500 error:

NoMethodError (undefined method `id' for nil:NilClass):
app/services/git_push_service.rb:42:in `sample_data'

Having a look at the line 42 we can see that it's calling commits.first or commits.last and doesn't manage when have no commit.