pre-upload: exit quickly when there are no hooks registered

If the repo hasn't enabled any hooks, then avoid running git to get
details about the current set of commits.  This speeds things up a
bit in the default case.

BUG=b:27812802
TEST=`repo upload` no longer chokes even when the active merge is bad

Change-Id: I9e5814dfe293100e70a5c99dacd2354e33391cd7
diff --git a/pre-upload.py b/pre-upload.py
index 55feaee..5156bbf 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -141,6 +141,11 @@
     # Hooks assume they are run from the root of the project.
     os.chdir(proj_dir)
 
+    # If the repo has no pre-upload hooks enabled, then just return.
+    hooks = list(_get_project_hooks())
+    if not hooks:
+        return True
+
     cmd = ['git', 'rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}']
     result = rh.utils.run_command(cmd, capture_output=True)
     remote_branch = result.output.strip()
@@ -163,8 +168,6 @@
     if not commit_list:
         commit_list = rh.git.get_commits()
 
-    hooks = _get_project_hooks()
-
     ret = True
     for commit in commit_list:
         # Mix in some settings for our hooks.