Add option to use pre-upload.py as a pre-submit hook

The new command line option (--pre-submit) forces the script to run
the check on the files prepared to be submitted as opposed to running
on the previously submitted patches.

This, among other things, requires filtering out several checks (those
applying to the commit message contents).

The 'commit' function argument throughout this script means 'the sha1
of a commit'. A special value ('pre-submit') is used to indicate that
the git command should operate not on a commit but on a cached change
prepared to be committed.

Checks involving checpatch.pl need to be amended to include the
--ignore=MISSING_SIGN_OFF command line option, as the commit message
is not available in this case.

BUG=none
TEST=manual
  . verified that ./pre-upload_unittest.py still passes

  . created bogus CLs in ~/trucnk/src/platform/depthcharge and
    ~/trunk/src/third_party/kernel/3.4 and observed proper error
    messages generated when running

   $ <path to>/pre-upload.py --pre-submit

    in those trees.

Change-Id: I023f983409ae0576ebb43a7b46e82cf319a959d5
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205172
1 file changed