Do not execute hooks on empty projects, fixes #6108

#### What does this MR do?

This PR fixes the problem executing a webhook on a empty project. If there are no commits yet on the repository, a flash message indicating the is shown. Fur successful executed hooks also a flash message is shown.

#### Why was this MR needed?

Currently, executing the *Test Hook* command on an empty project raises a 500 error. This PR fixes this.

#### What are the relevant issue numbers / Feature requests?

This PR fixes #6108

Redundant `begin` block detected.