pre-upload: fix running with upstream repo checkout

The pre-upload script has assumed that, when imported, the repo program
is running out of $CHROMEOS_CHECKOUT/.repo/repo/.  This is normally the
case when people use the repo launcher script from depot_tools.

This fails if repo is being run directly from somewhere else.  I've got
an upstream version of repo living in /usr/local/src/repo/ (to test the
latest version before we update), so the argv[0] trick no longer works.

Lets switch the logic to use a different fact: when the upload hook is
run, the cwd is always the top level of the repo checkout.  This is in
the upstream hook documentation.

TEST=`repo upload` works using local .repo/ and upstream versions

Change-Id: I5d805bb5d1f66b86c9776274205372e80e937df0
Commit-Ready: Mike Frysinger <>
Tested-by: Mike Frysinger <>
Reviewed-by: Luis Hector Chavez <>
1 file changed