Add more environment variables
This change adds REPO_LREV and REPO_RREV, both of which are set in `repo
forall`[1]. This also updates the doc for REPO_REMOTE to reflect the
reality since it does not always return the URL.
1: https://source.android.com/source/using-repo.html#forall
Bug: 33219807
Test: Added a pre-upload that called `env`, saw new fields.
Change-Id: Ifec0a3e05bc6832ead61baa5ccb0b5d2c29d948e
diff --git a/pre-upload.py b/pre-upload.py
index f15a9b7..447b8bf 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -205,14 +205,17 @@
# Set up the environment like repo would with the forall command.
try:
remote = rh.git.get_upstream_remote()
+ upstream_branch = rh.git.get_upstream_branch()
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_LREV': rh.git.get_commit_for_ref(upstream_branch),
'REPO_PATH': proj_dir,
+ 'REPO_PROJECT': project_name,
'REPO_REMOTE': remote,
+ 'REPO_RREV': rh.git.get_remote_revision(upstream_branch, remote),
})
output = Output(project_name, len(hooks))