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

Unified Diff: appengine/findit/common/chromium_deps.py

Issue 1950123003: [Findit] Fetch DEPS from buildspec/ instead of trunk for chrome official builds. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Address comments. 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
Index: appengine/findit/common/chromium_deps.py
diff --git a/appengine/findit/common/chromium_deps.py b/appengine/findit/common/chromium_deps.py
index 970b2df6dce69523948993dca745357711c35c59..a95996bd6127245efa93377f2b7b06b7d2676963 100644
--- a/appengine/findit/common/chromium_deps.py
+++ b/appengine/findit/common/chromium_deps.py
@@ -2,18 +2,35 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-from common import git_repository
-from common import http_client_appengine
+import base64
+import re
+
+from common import auth_util
from common import dependency
from common import deps_parser
-
+from common import git_repository
+from common import http_client_appengine
_CHROMIUM_ROOT_DIR = 'src/'
_CHROMIUM_REPO_MASTER = 'https://chromium.googlesource.com/chromium/src.git'
+_CHROME_VERSION_PATTERN = re.compile(r'^\d+\.\d+\.\d+\.\d+$')
+
+_BUILDSPEC_REPO = ('https://chrome-internal.googlesource.com/chrome/tools/'
+ 'buildspec.git/')
+
+
+def IsChromeVersion(revision):
+ """Determines if a revision is a chrome version."""
+ if _CHROME_VERSION_PATTERN.match(revision):
+ return True
+
+ return False
+
class DEPSDownloader(deps_parser.DEPSLoader):
"""Downloads DEPS from remote Git repo."""
+
def __init__(self, check_deps_git_first=False):
"""
Args:
@@ -23,10 +40,26 @@ class DEPSDownloader(deps_parser.DEPSLoader):
def Load(self, repo_url, revision, deps_file):
http_client = http_client_appengine.HttpClientAppengine()
- repo = git_repository.GitRepository(repo_url, http_client)
-
content = None
+ if IsChromeVersion(revision):
+ repo = git_repository.GitRepository(_BUILDSPEC_REPO, http_client)
stgao 2016/05/05 21:02:47 Can we handled both in the same way? In abstract,
Sharu Jiang 2016/05/05 23:03:45 Done.
+ url = '%s/+/master/releases/%s/%s' % (_BUILDSPEC_REPO, revision,
stgao 2016/05/05 21:02:46 Why can't we use the repo_url passed in here?
Sharu Jiang 2016/05/05 23:03:45 Done.
+ deps_file)
+ # The buildspec/ is a chrome internal repo, add header to verify the
+ # identity of the appengine app based on the service account.
+ headers = {'Authorization': 'Bearer ' + auth_util.GetAuthToken()}
+ content = repo._SendRequestForTextResponse(url, headers=headers)
stgao 2016/05/05 21:02:47 Class-internal functions like this are not suppose
Sharu Jiang 2016/05/05 23:03:45 Done.
+
+ if content is None:
+ raise Exception(
+ 'Failed to pull %s file from buildspec/ for version %s.' % (
+ deps_file, revision))
+
+ return content
+
+ repo = git_repository.GitRepository(repo_url, http_client)
+
if self.check_deps_git_first and deps_file == 'DEPS':
# When the given deps_file is "DEPS" and .DEPS.git should be checked
# first, it's because before migration from SVN to Git, .DEPS.git contains
@@ -50,9 +83,10 @@ def GetChromeDependency(revision, platform, check_deps_git_first=False):
"""Returns all dependencies of Chrome as a dict for the given revision and OS.
Args:
- revision (str): The revision of a Chrome build.
+ revision (str): The revision of a Chrome build, it can be a githash or a
+ chrome version for a official build.
platform (str): The target platform of the Chrome build, should be one of
- 'win', 'ios', 'mac', 'unix', 'android', or 'all'.
+ 'win', 'ios', 'mac', 'unix', 'android', or 'all'.
check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS.
Returns:
@@ -61,8 +95,14 @@ def GetChromeDependency(revision, platform, check_deps_git_first=False):
root_dep = dependency.Dependency(
_CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER, revision, 'DEPS')
- deps_parser.UpdateDependencyTree(
- root_dep, [platform], DEPSDownloader(check_deps_git_first))
+ deps_parser.UpdateDependencyTree(root_dep, [platform],
+ DEPSDownloader(check_deps_git_first))
+
+ if IsChromeVersion(root_dep.revision):
+ http_client = http_client_appengine.HttpClientAppengine()
+ repo = git_repository.GitRepository(_CHROMIUM_REPO_MASTER, http_client)
+ # Convert chrome version to githash revision to be consistent.
+ root_dep.revision = repo.GetRevisionForChromeVersion(root_dep.revision)
dependencies = {}
@@ -78,14 +118,21 @@ def GetChromeDependency(revision, platform, check_deps_git_first=False):
def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform,
- check_deps_git_first=False):
+ check_deps_git_first=False, skip_chromium_roll=True):
"""Returns a list of dependency rolls between the given Chromium revisions.
Args:
- old_cr_revision (str): The Git commit hash for the old Chromium revision.
- new_cr_revision (str): The Git commit hash for the new Chromium revision.
+ old_cr_revision (str): The old Chromium revision, it can be a githash or a
+ chrome version for a official build.
+ new_cr_revision (str): The new Chromium revision, it can be a githash or a
+ chrome version for a official build.
platform (str): The target OS platform of the Chrome or test binary.
check_deps_git_first (bool): If True, use .DEPS.git instead of DEPS.
+ skip_chromium_roll (bool): If False, chromium roll will be contained in
+ the return.
+
+ Returns:
+ A list of DependencyRoll objects in the revision range.
"""
old_deps = GetChromeDependency(
old_cr_revision, platform, check_deps_git_first)
@@ -95,7 +142,7 @@ def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform,
rolls = []
for path, new_dep in new_deps.iteritems():
- if path == _CHROMIUM_ROOT_DIR: # Skip the root dependency -- chromium.
+ if skip_chromium_roll and path == _CHROMIUM_ROOT_DIR:
continue
old_revision = None
@@ -117,22 +164,20 @@ def GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform,
def GetDEPSRollsDict(old_cr_revision, new_cr_revision, platform):
- """Gets dep_path to DependencyRoll dictionary for deps in
- (old_cr_revision, new_cr_revision].
+ """Gets dep_path to DependencyRoll dictionary for deps between revisions.
Args:
- old_cr_revision (str): The Git commit hash for the old Chromium revision.
- new_cr_revision (str): The Git commit hash for the new Chromium revision.
+ old_cr_revision (str): The old Chromium revision, it can be a githash or a
+ chrome version for a official build.
+ new_cr_revision (str): The new Chromium revision, it can be a githash or a
+ chrome version for a official build.
platform (str): The target OS platform of the Chrome or test binary.
Returns:
- A dict, mapping dep path to DependencyRoll.
+ A dict, mapping dep path to its DependencyRoll.
"""
- deps_rolls = GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform)
- # Add chromium as dependency roll.
- deps_rolls.append(dependency.DependencyRoll(
- _CHROMIUM_ROOT_DIR, _CHROMIUM_REPO_MASTER,
- old_cr_revision, new_cr_revision))
+ deps_rolls = GetChromiumDEPSRolls(old_cr_revision, new_cr_revision, platform,
+ skip_chromium_roll=False)
deps_rolls_dict = {}
for dep_roll in deps_rolls:

Powered by Google App Engine
This is Rietveld 408576698