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

Unified Diff: recipe_engine/package.py

Issue 2071443003: Introduce different repo types (git and gitiles) (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: 80cols Created 4 years, 6 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
Index: recipe_engine/package.py
diff --git a/recipe_engine/package.py b/recipe_engine/package.py
index 0102e0163f7f9100c43d0b86192af540881defaa..a02b3143f75c80c9b4966c45c75ae0e356c38a61 100644
--- a/recipe_engine/package.py
+++ b/recipe_engine/package.py
@@ -170,12 +170,13 @@ class RepoSpec(object):
class GitRepoSpec(RepoSpec):
- def __init__(self, project_id, repo, branch, revision, path):
+ def __init__(self, project_id, repo, branch, revision, path, backend):
self.project_id = project_id
self.repo = repo
self.branch = branch
self.revision = revision
self.path = path
+ self.backend = backend
def __str__(self):
return ('GitRepoSpec{project_id="%(project_id)s", repo="%(repo)s", '
@@ -193,7 +194,7 @@ class GitRepoSpec(RepoSpec):
def checkout(self, context):
checkout_dir = self._dep_dir(context)
- fetch.ensure_git_checkout(
+ self.backend.checkout(
self.repo, self.revision, checkout_dir, context.allow_fetch)
cleanup_pyc(checkout_dir)
@@ -220,7 +221,12 @@ class GitRepoSpec(RepoSpec):
for rev in raw_updates:
info = self._get_commit_info(rev, context)
updates.append(GitRepoSpec(
- self.project_id, self.repo, self.branch, rev, self.path))
+ self.project_id,
+ self.repo,
+ self.branch,
+ rev,
+ self.path,
+ self.backend))
return updates
def commit_infos(self, context, other_revision):
@@ -487,15 +493,21 @@ class PackageSpec(object):
@classmethod
def spec_for_dep(cls, dep):
- """Returns a RepoSpec for the given dependency protobuf.
-
- This assumes all dependencies are Git dependencies.
- """
- return GitRepoSpec(str(dep.project_id),
- str(dep.url),
- str(dep.branch),
- str(dep.revision),
- str(dep.path_override))
+ """Returns a RepoSpec for the given dependency protobuf."""
+
+ if dep.repo_type in (package_pb2.DepSpec.GIT, package_pb2.DepSpec.GITILES):
+ if dep.repo_type == package_pb2.DepSpec.GIT:
+ backend = fetch.LocalGitBackend()
+ elif dep.repo_type == package_pb2.DepSpec.GITILES:
+ backend = fetch.GitilesGitBackend()
+ return GitRepoSpec(str(dep.project_id),
+ str(dep.url),
+ str(dep.branch),
+ str(dep.revision),
+ str(dep.path_override),
+ backend)
+
+ assert False, 'Unexpected repo type: %s' % dep
@property
def project_id(self):

Powered by Google App Engine
This is Rietveld 408576698