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

Unified Diff: deps2git/deps2submodules.py

Issue 10544140: Sometimes DEPS will not pin a revision for a dependency, but just let it float (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/
Patch Set: Minimize work to find remote HEAD for floating dependencies Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: deps2git/deps2submodules.py
===================================================================
--- deps2git/deps2submodules.py (revision 141914)
+++ deps2git/deps2submodules.py (working copy)
@@ -19,7 +19,7 @@
{ submod_name : [ submod_os, submod_url, submod_sha1 ], ... }
"""
fixdep = lambda x: x[4:] if x.startswith('src/') else x
- spliturl = lambda x: x.split('@', 1)
+ spliturl = lambda x: list(x.partition('@')[0::2])
submods = {}
for (dep, url) in deps_content[0].iteritems():
submods[fixdep(dep)] = ['all'] + spliturl(url)
@@ -41,6 +41,18 @@
print >>fh, '\tpath = %s' % submod
print >>fh, '\turl = %s' % submod_url
print >>fh, '\tos = %s' % submod_os
+ if not submod_sha1:
+ # We don't know what sha1 to register, so we have to infer it from the
+ # submodule's origin/master.
+ if not os.path.exists(os.path.join(submod, '.git')):
+ # Not cloned yet
+ subprocess.check_call(['git', 'clone', '-n', submod_url, submod])
+ else:
+ # Already cloned; let's fetch
+ subprocess.check_call(['git', 'fetch', 'origin'], cwd=submod)
+ sub = subprocess.Popen(['git', 'rev-list', 'origin/HEAD^!'],
+ cwd=submod, stdout=subprocess.PIPE)
+ submod_sha1 = sub.communicate()[0].rstrip()
subprocess.check_call(['git', 'update-index', '--add',
'--cacheinfo', '160000', submod_sha1, submod])
fh.close()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698