Allow running the pre-upload hook outside of the context of repo.

This can be useful for two things:
1. Running hooks itself without running 'repo upload'.  This might
   be useful since it should be a bit quicker.
2. Running hooks even if you don't have a full Chromium OS checkout.
   In this case, you could just fetch down the hooks and a project,
   then run the hooks directly.  In this mode, the '--project' option
   is required.

BUG=None
TEST=Ran pre-upload hooks in the context of repo (ran repo upload).

TEST=Ran doctests:
1. Ran .../hooks/pre-upload.py --test -v

TEST=Ran pre-upload hooks in a bare checkout of u-boot:
1. mkdir /tmp/pureuboot
2. cd /tmp/pureuboot/
3. git init
4. git remote add cros http://git.chromium.org/git/chromiumos/third_party/u-boot
5. git fetch cros
6. git checkout -b testing --track cros/master
7. echo '  foobar  ' >> Makefile
8. git commit -am "testing"
9. .../hooks/pre-upload.py --project=chromiumos/third_party/u-boot
10. Saw hook report an error (including signed-off-by, showing that we got
    u-boot hooks).

TEST=Ran pre-upload hooks manually in chromiumos checkout:
1. cd ~/chromiumos/src/third_party/u-boot/files
2. repo start testing .
3. echo '  foobar  ' >> Makefile
4. git commit -am "testing"
5. ~/chromiumos/src/repohooks/pre-upload.py
6. Saw hook report an error (including signed-off-by, showing that we got
   u-boot hooks).

Change-Id: Ia9ee51d21bba5a3fdc94f140e2d2308ed97f0273
Reviewed-on: https://gerrit.chromium.org/gerrit/11056
Tested-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Mandeep Singh Baines <msb@chromium.org>
1 file changed