project_sdk: Rename FindSourceRoot to FindRepoRoot.
This utility method had a confusing name, especially in a world with
workspaces. So... rename it.
BUG=None
TEST=lint + unittests
Change-Id: I4e2ee78f25566d2772450bd522fafb3294869806
Reviewed-on: https://chromium-review.googlesource.com/262436
Trybot-Ready: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: David Pursell <dpursell@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
diff --git a/cli/brillo/brillo_sdk.py b/cli/brillo/brillo_sdk.py
index 814ba67..9ccd184 100644
--- a/cli/brillo/brillo_sdk.py
+++ b/cli/brillo/brillo_sdk.py
@@ -29,13 +29,13 @@
def _UpdateWorkspaceSdk(self, bootstrap_path, workspace_path, version):
"""Install specified SDK, and associate the workspace with it."""
- if project_sdk.FindSourceRoot(bootstrap_path):
+ if project_sdk.FindRepoRoot(bootstrap_path):
cros_build_lib.Die('brillo sdk must run from a git clone. brbug.com/580')
sdk_path = bootstrap_lib.ComputeSdkPath(bootstrap_path, version)
# If this version already exists, no need to reinstall it.
- if not project_sdk.FindSourceRoot(sdk_path):
+ if not project_sdk.FindRepoRoot(sdk_path):
self._UpdateSdk(sdk_path, version)
# Store the new version in the workspace.
@@ -89,7 +89,7 @@
def _SelfUpdate(self, bootstrap_path):
"""Update the bootstrap repository."""
# If our bootstrap is part of a repository, we shouldn't update.
- if project_sdk.FindSourceRoot(bootstrap_path):
+ if project_sdk.FindRepoRoot(bootstrap_path):
return
# If the 'skip update' variable is set, we shouldn't update.
diff --git a/lib/project_sdk.py b/lib/project_sdk.py
index 518fafb..051ecf1 100644
--- a/lib/project_sdk.py
+++ b/lib/project_sdk.py
@@ -13,7 +13,7 @@
from chromite.lib import osutils
-def FindSourceRoot(sdk_dir=None):
+def FindRepoRoot(sdk_dir=None):
"""Locate the SDK root directly by looking for .repo dir.
This is very similar to constants.SOURCE_ROOT, except that it can operate
@@ -63,7 +63,7 @@
The version of your SDK as a string. '6500.0.0'
None if the directory doesn't appear to be an SDK.
"""
- sdk_root = FindSourceRoot(sdk_dir)
+ sdk_root = FindRepoRoot(sdk_dir)
if sdk_root is None:
return None
diff --git a/lib/project_sdk_unittest.py b/lib/project_sdk_unittest.py
index 8545713..ed40645 100644
--- a/lib/project_sdk_unittest.py
+++ b/lib/project_sdk_unittest.py
@@ -50,26 +50,26 @@
osutils.Touch(real_manifest_path, makedirs=True)
os.symlink(real_manifest_path, sym_manifest_path)
- def testFindSourceRootCurrentRepo(self):
- """Test FindSourceRoot with default of CWD."""
- self.assertEqual(constants.SOURCE_ROOT, project_sdk.FindSourceRoot())
+ def testFindRepoRootCurrentRepo(self):
+ """Test FindRepoRoot with default of CWD."""
+ self.assertEqual(constants.SOURCE_ROOT, project_sdk.FindRepoRoot())
- def testFindSourceRootSpecifiedBogus(self):
- """Test FindSourceRoot with non-existent directory outside the repo."""
- self.assertIsNone(project_sdk.FindSourceRoot(self.bogus_dir))
+ def testFindRepoRootSpecifiedBogus(self):
+ """Test FindRepoRoot with non-existent directory outside the repo."""
+ self.assertIsNone(project_sdk.FindRepoRoot(self.bogus_dir))
- def testFindSourceRootSpecifiedRoot(self):
- """Test FindSourceRoot with top level of repo tree."""
- self.assertEqual(self.repo_dir, project_sdk.FindSourceRoot(self.repo_dir))
+ def testFindRepoRootSpecifiedRoot(self):
+ """Test FindRepoRoot with top level of repo tree."""
+ self.assertEqual(self.repo_dir, project_sdk.FindRepoRoot(self.repo_dir))
- def testFindSourceRootSpecifiedNested(self):
- """Test FindSourceRoot with nested inside repo tree."""
- self.assertEqual(self.repo_dir, project_sdk.FindSourceRoot(self.nested_dir))
+ def testFindRepoRootSpecifiedNested(self):
+ """Test FindRepoRoot with nested inside repo tree."""
+ self.assertEqual(self.repo_dir, project_sdk.FindRepoRoot(self.nested_dir))
- def testFindSourceRootSpecifiedNonexistent(self):
- """Test FindSourceRoot refuses to scan a nonexistent path."""
+ def testFindRepoRootSpecifiedNonexistent(self):
+ """Test FindRepoRoot refuses to scan a nonexistent path."""
self.assertIsNone(
- project_sdk.FindSourceRoot(os.path.join(self.nested_dir, 'not_there')))
+ project_sdk.FindRepoRoot(os.path.join(self.nested_dir, 'not_there')))
def testFindVersionDefault(self):
"""Test FindVersion with default of CWD."""