Coming from CVS, we have a policy that commit messages should be tagged with a bug number (simple suffix \"... [9999]\"). A CVS script checks this during commits and rejects
You didn't mention what is your bug tracker, but if it is JIRA, then the add-on named Commit Policy can do this for without any programming.
You can set up a commit condition which requires the commit message to match a regular expression. If it doesn't, the push is rejected, and the developer must amend (fix) the commit message, then push again.