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

Unified Diff: recipe_engine/package.py

Issue 1997023002: recipe engine: add remote_run command (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: trybots Created 4 years, 7 months 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 | « recipe_engine/fetch.py ('k') | recipe_engine/remote_run.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/package.py
diff --git a/recipe_engine/package.py b/recipe_engine/package.py
index d9224f1de4682165e7f7b362e32e1afd1bab7c44..bec8aa01251da5e3148106fbf864460c74bcba9d 100644
--- a/recipe_engine/package.py
+++ b/recipe_engine/package.py
@@ -18,14 +18,7 @@ import tempfile
from .third_party.google.protobuf import text_format
from . import package_pb2
-
-
-class UncleanFilesystemError(Exception):
- pass
-
-
-class FetchNotAllowedError(Exception):
- pass
+from . import fetch
class InconsistentDependencyGraphError(Exception):
@@ -44,6 +37,7 @@ class CyclicDependencyError(Exception):
def cleanup_pyc(path):
"""Removes any .pyc files from |path|'s directory tree.
+
This ensures we always use the fresh code.
"""
for root, dirs, files in os.walk(path):
@@ -223,29 +217,10 @@ class GitRepoSpec(RepoSpec):
return subprocess.check_output(cmd)
def checkout(self, context):
- dep_dir = self._dep_dir(context)
- logging.info('Freshening repository %s', dep_dir)
-
- if not os.path.isdir(dep_dir):
- if context.allow_fetch:
- self.run_git(None, 'clone', '-q', self.repo, dep_dir)
- else:
- raise FetchNotAllowedError(
- 'need to clone %s but fetch not allowed' % self.repo)
- elif not os.path.isdir(os.path.join(dep_dir, '.git')):
- raise UncleanFilesystemError('%s exists but is not a git repo' % dep_dir)
-
- try:
- self.run_git(context, 'rev-parse', '-q', '--verify',
- '%s^{commit}' % self.revision)
- except subprocess.CalledProcessError:
- if context.allow_fetch:
- self.run_git(context, 'fetch')
- else:
- raise FetchNotAllowedError(
- 'need to fetch %s but fetch not allowed' % self.repo)
- self.run_git(context, 'reset', '-q', '--hard', self.revision)
- cleanup_pyc(dep_dir)
+ checkout_dir = self._dep_dir(context)
+ fetch.ensure_git_checkout(
+ self.repo, self.revision, checkout_dir, context.allow_fetch)
+ cleanup_pyc(checkout_dir)
def repo_root(self, context):
return os.path.join(self._dep_dir(context), self.path)
« no previous file with comments | « recipe_engine/fetch.py ('k') | recipe_engine/remote_run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698