Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Unified Diff: lib/cros_build_lib.py

Issue 4442001: Add more error checking to preflight queue. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git
Patch Set: Fix bug in FindRepoDir Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cros_mark_as_stable.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cros_build_lib.py
diff --git a/lib/cros_build_lib.py b/lib/cros_build_lib.py
index 509871c6eedbe06ad9b9e160930e4eae4a3f2fa5..e396b30abfb8635deeb95c92456e046ae227ad7c 100644
--- a/lib/cros_build_lib.py
+++ b/lib/cros_build_lib.py
@@ -138,14 +138,19 @@ def Info(message):
Color(_STDOUT_IS_TTY).Color(Color.BLUE, '\nINFO: ' + message))
-def FindRepoDir():
- """Returns the nearest higher-level repo dir from the cwd."""
- cwd = os.getcwd()
- while cwd != '/':
- repo_dir = os.path.join(cwd, '.repo')
+def FindRepoDir(path=None):
+ """Returns the nearest higher-level repo dir from the specified path.
+
+ Args:
+ path: The path to use. Defaults to cwd.
+ """
+ if path is None:
+ path = os.getcwd()
+ while path != '/':
+ repo_dir = os.path.join(path, '.repo')
if os.path.isdir(repo_dir):
return repo_dir
- cwd = os.path.dirname(cwd)
+ path = os.path.dirname(path)
return None
@@ -155,7 +160,7 @@ def ReinterpretPathForChroot(path):
Keyword arguments:
path: The path to reinterpret. Must be in src tree.
"""
- root_path = os.path.join(FindRepoDir(), '..')
+ root_path = os.path.join(FindRepoDir(path), '..')
path_abs_path = os.path.abspath(path)
root_abs_path = os.path.abspath(root_path)
« no previous file with comments | « cros_mark_as_stable.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698