githooks: overhaul presubmit checks; automatically apply fixes

This CL rewrites our githooks in Python, since bash makes this
moderately ugly.

The Killer Feature(TM) here is that we now also try to execute the
commands that we recommend the user to run. This makes fixing many "yapf
disagrees with you" / "you're missing a #!"-style messages as simple as
`git commit --amend -a`.

Note that these fixes are only auto-applied if your current repo is
clean.

BUG=None
TEST=Various broken and configs in and outside of the chroot. I was also
     able to `repo upload` with it. :)
Change-Id: Id841fa02271c0d03debbf35681eba8151074672e
Reviewed-on: https://chromium-review.googlesource.com/1897253
Tested-by: George Burgess <gbiv@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Denis Nikitin <denik@chromium.org>
5 files changed