Commit 3d894aa4 authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

bot_update: Fix manifest creation.

It fails when both the revision and the url are None.

Bug: 841936
Change-Id: Idef45a015624a92226d4ccd38ed5b978bf786993
Reviewed-on: https://chromium-review.googlesource.com/1053996
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: 's avatarRyan Tseng <hinoka@chromium.org>
parent 21913086
......@@ -457,7 +457,7 @@ def create_manifest(gclient_output, patch_root, gerrit_ref):
the directory -> repo:revision mapping.
* Gerrit Patch info which contains info about patched revisions.
We normalize the URLs such that if they are googlesource.com urls, they:
We normalize the URLs using the normalize_git_url function.
"""
manifest = {
'version': 0, # Currently the only valid version is 0.
......@@ -467,21 +467,16 @@ def create_manifest(gclient_output, patch_root, gerrit_ref):
patch_root = patch_root.strip('/') # Normalize directory names.
for directory, info in gclient_output.get('solutions', {}).iteritems():
directory = directory.strip('/') # Normalize the directory name.
# There are two places to the the revision from, we do it in this order:
# 1. In the "revision" field
# 2. At the end of the URL, after @
repo = ''
revision = info.get('revision', '')
# The format of the url is "https://repo.url/blah.git@abcdefabcdef" or
# just "https://repo.url/blah.git"
url_split = info.get('url')
if url_split is not None:
url_split = url_split.split('@')
if not revision and len(url_split) == 2:
revision = url_split[1]
if url_split:
repo = normalize_git_url(url_split[0])
if repo:
url = info.get('url') or ''
repo, _, url_revision = url.partition('@')
repo = normalize_git_url(repo)
# There are two places to get the revision from, we do it in this order:
# 1. In the "revision" field
# 2. At the end of the URL, after @
revision = info.get('revision') or url_revision
if repo and revision:
dirs[directory] = {
'git_checkout': {
'repo_url': repo,
......
......@@ -258,23 +258,27 @@ class BotUpdateUnittests(unittest.TestCase):
def testGenerateManifestsBasic(self):
gclient_output = {
'solutions': {
'breakpad/': {
'revision': None,
'scm': None,
'url': ('https://chromium.googlesource.com/breakpad/breakpad.git' +
'@5f638d532312685548d5033618c8a36f73302d0a')
},
"src/": {
'revision': 'f671d3baeb64d9dba628ad582e867cf1aebc0207',
'scm': None,
'url': 'https://chromium.googlesource.com/a/chromium/src.git'
},
}
'solutions': {
'breakpad/': {
'revision': None,
'scm': None,
'url': ('https://chromium.googlesource.com/breakpad.git' +
'@5f638d532312685548d5033618c8a36f73302d0a')
},
"src/": {
'revision': 'f671d3baeb64d9dba628ad582e867cf1aebc0207',
'scm': None,
'url': 'https://chromium.googlesource.com/a/chromium/src.git'
},
'src/overriden': {
'revision': None,
'scm': 'git',
'url': None,
},
}
}
out = bot_update.create_manifest(gclient_output, None, None)
self.assertEquals(len(out['directories']), 2)
print out
self.assertEquals(
out['directories']['src']['git_checkout']['revision'],
'f671d3baeb64d9dba628ad582e867cf1aebc0207')
......@@ -286,7 +290,8 @@ class BotUpdateUnittests(unittest.TestCase):
'5f638d532312685548d5033618c8a36f73302d0a')
self.assertEquals(
out['directories']['breakpad']['git_checkout']['repo_url'],
'https://chromium.googlesource.com/breakpad/breakpad')
'https://chromium.googlesource.com/breakpad')
self.assertNotIn('src/overridden', out['directories'])
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment