aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-06-06 14:06:18 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-06-06 14:06:18 +0000
commit6ca9412c1ba65e255924a403165d60949bfebd50 (patch)
tree634384146ccd8abc0fe54bae85af8d61e24dda43
parent3afcd28e561824bbe39f58dfc59f7a927e6bf927 (diff)
parent669d9839bcc5dcaffad72ccab65d0f2844661a9f (diff)
downloadrepohooks-androidx-graphics-shapes-release.tar.gz
Merge "repohooks: pass through REPO_PROJECT" into mainandroidx-graphics-shapes-release
-rw-r--r--README.md3
-rw-r--r--rh/hooks.py5
-rwxr-xr-xrh/hooks_unittest.py7
3 files changed, 15 insertions, 0 deletions
diff --git a/README.md b/README.md
index 7befb53..9b855ec 100644
--- a/README.md
+++ b/README.md
@@ -114,6 +114,9 @@ Some variables are available to make it easier to handle OS differences. These
are automatically expanded for you:
* `${REPO_PATH}`: The path to the project relative to the root.
+ e.g. `tools/repohooks`
+* `${REPO_PROJECT}`: The name of the project.
+ e.g. `platform/tools/repohooks`
* `${REPO_ROOT}`: The absolute path of the root of the repo checkout. If the
project is in a submanifest, this points to the root of the submanifest.
* `${REPO_OUTER_ROOT}`: The absolute path of the root of the repo checkout.
diff --git a/rh/hooks.py b/rh/hooks.py
index 7f62713..453f74e 100644
--- a/rh/hooks.py
+++ b/rh/hooks.py
@@ -134,6 +134,11 @@ class Placeholders(object):
return os.environ.get('REPO_PATH', '')
@property
+ def var_REPO_PROJECT(self):
+ """The name of the project"""
+ return os.environ.get('REPO_PROJECT', '')
+
+ @property
def var_REPO_ROOT(self):
"""The root of the repo (sub-manifest) checkout."""
return rh.git.find_repo_root()
diff --git a/rh/hooks_unittest.py b/rh/hooks_unittest.py
index 0bb7726..389fe07 100755
--- a/rh/hooks_unittest.py
+++ b/rh/hooks_unittest.py
@@ -197,6 +197,13 @@ class PlaceholderTests(unittest.TestCase):
os.environ['REPO_PATH'] = 'foo/bar'
self.assertEqual(self.replacer.get('REPO_PATH'), 'foo/bar')
+ def testREPO_PROJECT(self):
+ """Verify handling of REPO_PROJECT."""
+ os.environ['REPO_PROJECT'] = ''
+ self.assertEqual(self.replacer.get('REPO_PROJECT'), '')
+ os.environ['REPO_PROJECT'] = 'platform/foo/bar'
+ self.assertEqual(self.replacer.get('REPO_PROJECT'), 'platform/foo/bar')
+
@mock.patch.object(rh.hooks, '_get_build_os_name', return_value='vapier os')
def testBUILD_OS(self, m):
"""Verify handling of BUILD_OS."""