hooks: Make the error when upstream not found more actionable
Currently a stack trace is spit when a change is tried to be uploaded
before running `repo start` on a project. This change replaces that
stack trace with a terser error and instructions to run repo start.
Bug: None
Test: Tried to upload this before calling repo start. Complained.
Change-Id: I01578041fe8fab954c53e8d66750ca6160c62f33
diff --git a/pre-upload.py b/pre-upload.py
index 81720a5..ec723e1 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -158,7 +158,12 @@
return True
# Set up the environment like repo would with the forall command.
- remote = rh.git.get_upstream_remote()
+ try:
+ remote = rh.git.get_upstream_remote()
+ except rh.utils.RunCommandError as e:
+ print('upstream remote cannot be found: %s' % (e,), file=sys.stderr)
+ print('Did you run repo start?', file=sys.stderr)
+ sys.exit(1)
os.environ.update({
'REPO_PROJECT': project_name,
'REPO_PATH': proj_dir,