summaryrefslogtreecommitdiffstats
path: root/tools/scripts
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-09-10 19:48:56 +0200
committerAndras Becsi <andras.becsi@digia.com>2014-09-11 12:22:21 +0200
commitd741059422ebeb1613c767bdd318c87228ec2160 (patch)
treefca80cef23e13d828a65124f652bdfcb1a223535 /tools/scripts
parentde2d1a6d8ab61db7e6994c414a08f1a6ba7afb9b (diff)
init-repository: clean up upstream repository checkout even more
Remove unneeded codepaths now that we can trust the git shasums found in the .DEPS.git file. No need for parsing and verifying remote branches, we can simply fetch the specified sha1 from origin. This patch also unifies the 'shasum' and 'ref' members of the Submodule python class since the 'ref' member can represent both chromium's version tag and the sha1s of the submodules, there is no need for a separate codepath for these. Change-Id: I1300b5b74f4d2e6984943570963b2f813b1b1679 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'tools/scripts')
-rw-r--r--tools/scripts/git_submodule.py49
-rwxr-xr-xtools/scripts/init-repository.py2
-rw-r--r--tools/scripts/version_resolver.py19
3 files changed, 23 insertions, 47 deletions
diff --git a/tools/scripts/git_submodule.py b/tools/scripts/git_submodule.py
index f3508eac..bc311f97 100644
--- a/tools/scripts/git_submodule.py
+++ b/tools/scripts/git_submodule.py
@@ -90,12 +90,9 @@ class DEPSParser:
continue
if len(rev) == 40: # Length of a git shasum
- submodule.shasum = rev
+ submodule.ref = rev
else:
- # Try to find out the git branch.
- branchMatch = re.search('/branches/((chromium/)?[^/]+)', repo)
- if branchMatch:
- submodule.ref = 'refs/branch-heads/' + branchMatch.group(1)
+ sys.exit("Invalid shasum: " + str(rev))
submodules.append(submodule)
return submodules
@@ -109,12 +106,11 @@ class DEPSParser:
return submodules
class Submodule:
- def __init__(self, path='', url='', shasum='', os=[], ref=''):
+ def __init__(self, path='', url='', ref='', os=[]):
self.path = path
self.url = url
- self.shasum = shasum
+ self.ref = ref
self.os = os
- self.ref = ''
def matchesOS(self):
if not self.os:
@@ -139,35 +135,34 @@ class Submodule:
def findShaAndCheckout(self):
oldCwd = os.getcwd()
os.chdir(self.path)
- error = 0
- if self.ref:
- # Fetch the ref we parsed from the DEPS file.
- error = subprocessCall(['git', 'fetch', 'origin', self.ref])
- if error != 0:
- print('ERROR: Could not fetch from upstream branch ' + self.ref)
- return error
- error = subprocessCall(['git', 'checkout', 'FETCH_HEAD']);
+ # Fetch the shasum we parsed from the DEPS file.
+ error = subprocessCall(['git', 'fetch', 'origin', self.ref])
+ if error != 0:
+ print('ERROR: Could not fetch ' + self.ref + ' from upstream origin.')
+ return error
+
+ error = subprocessCall(['git', 'checkout', 'FETCH_HEAD']);
current_shasum = subprocessCheckOutput(['git', 'rev-parse', 'HEAD']).strip()
current_tag = subprocessCheckOutput(['git', 'name-rev', '--tags', '--name-only', current_shasum]).strip()
if current_tag == resolver.currentVersion():
# We checked out a tagged version of chromium.
- self.shasum = current_shasum
+ self.ref = current_shasum
- if not self.shasum:
+ if not self.ref:
# No shasum could be deduced, use the submodule shasum.
os.chdir(oldCwd)
line = subprocessCheckOutput(['git', 'submodule', 'status', self.path])
os.chdir(self.path)
line = line.lstrip(' -')
- self.shasum = line.split(' ')[0]
+ self.ref = line.split(' ')[0]
- if not self.shasum.startswith(current_shasum):
+ if not self.ref.startswith(current_shasum):
# In case HEAD differs check out the actual shasum we require.
subprocessCall(['git', 'fetch'])
- error = subprocessCall(['git', 'checkout', self.shasum])
+ error = subprocessCall(['git', 'checkout', self.ref])
os.chdir(oldCwd)
return error
@@ -207,10 +202,10 @@ class Submodule:
subprocessCall(['git', 'submodule', 'init', self.path])
subprocessCall(['git', 'submodule', 'update', self.path])
- if self.findShaAndCheckout() != 0:
- sys.exit("!!! initialization failed !!!")
-
if '3rdparty_upstream' in os.path.abspath(self.path):
+ if self.findShaAndCheckout() != 0:
+ sys.exit("!!! initialization failed !!!")
+
# Add baseline commit for upstream repository to be able to reset.
os.chdir(self.path)
commit = subprocessCheckOutput(['git', 'rev-list', '--max-count=1', 'HEAD'])
@@ -238,8 +233,7 @@ class Submodule:
submodules = resolver.readSubmodules()
print 'DEPS file provides the following submodules:'
for submodule in submodules:
- submodule_ref = submodule.shasum
- print '{:<80}'.format(submodule.path) + '{:<120}'.format(submodule.url) + submodule_ref
+ print '{:<80}'.format(submodule.path) + '{:<120}'.format(submodule.url) + submodule.ref
else: # Try .gitmodules since no ref has been specified
if not os.path.isfile('.gitmodules'):
return []
@@ -274,6 +268,5 @@ class Submodule:
submodules = self.readSubmodules()
for submodule in submodules:
submodule.initialize()
- if self.ref:
- subprocessCall(['git', 'commit', '-a', '--amend', '--no-edit'])
+ subprocessCall(['git', 'commit', '-a', '--amend', '--no-edit'])
os.chdir(oldCwd)
diff --git a/tools/scripts/init-repository.py b/tools/scripts/init-repository.py
index 1141ee98..3425649f 100755
--- a/tools/scripts/init-repository.py
+++ b/tools/scripts/init-repository.py
@@ -110,7 +110,7 @@ def initUpstreamSubmodules():
ninjaSubmodule = GitSubmodule.Submodule()
ninjaSubmodule.path = 'src/3rdparty_upstream/ninja'
- ninjaSubmodule.shasum = ninja_shasum
+ ninjaSubmodule.ref = ninja_shasum
ninjaSubmodule.url = ninja_url
ninjaSubmodule.os = 'all'
ninjaSubmodule.initialize()
diff --git a/tools/scripts/version_resolver.py b/tools/scripts/version_resolver.py
index d3d82094..2430555d 100644
--- a/tools/scripts/version_resolver.py
+++ b/tools/scripts/version_resolver.py
@@ -86,23 +86,6 @@ def readReleaseChannels():
channels[os].append({ 'channel': ver['channel'], 'version': ver['version'], 'branch': ver['true_branch'] })
return channels
-def sanityCheckModules(submodules):
- submodule_dict = {}
- sys.stdout.write('\nverifying submodule refs.')
- for submodule in submodules:
- sys.stdout.flush()
- if submodule.ref:
- sys.stdout.write('.')
- result = subprocess.check_output(['git', 'ls-remote', submodule.url, submodule.ref])
- if submodule.ref not in result:
- # We could fall back to the git shasum if the parsed remote ref does not exist in
- # the git repository but that would most certainly be outdated, so bail out here.
- sys.exit('\nERROR: No valid remote found!')
- sys.stdout.flush()
- submodule_dict[submodule.path] = submodule
- print('done.\n')
- return list(submodule_dict.values())
-
def readSubmodules():
git_deps = subprocess.check_output(['git', 'show', chromium_version +':.DEPS.git'])
@@ -119,7 +102,7 @@ def readSubmodules():
if path in submodule_dict:
del submodule_dict[path]
- return sanityCheckModules(submodule_dict.values())
+ return submodule_dict.values()
def findSnapshotBaselineSha1():
if not os.path.isdir(snapshot_src_dir):