share code between pre-commit and pre-review hooks

Change-Id: I682be3fc8856fe9e885d9a1f6eeac4ed9a5f93fd