Index: recipe_engine/package.py |
diff --git a/recipe_engine/package.py b/recipe_engine/package.py |
index d9224f1de4682165e7f7b362e32e1afd1bab7c44..cc2c3b72bc35d5eb8a9b9a3d74c3acc329c230e8 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): |
@@ -42,16 +35,6 @@ class CyclicDependencyError(Exception): |
pass |
-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): |
- for f in files: |
- if f.endswith('.pyc'): |
- os.unlink(os.path.join(root, f)) |
- |
- |
class InfraRepoConfig(object): |
def to_recipes_cfg(self, repo_root): |
# TODO(luqui): This is not always correct. It can be configured in |
@@ -223,29 +206,8 @@ 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) |
+ fetch.fetch_from_git( |
+ self.repo, self.revision, self._dep_dir(context), context.allow_fetch) |
def repo_root(self, context): |
return os.path.join(self._dep_dir(context), self.path) |