diff --git a/recipes/recipe_modules/bot_update/resources/bot_update.py b/recipes/recipe_modules/bot_update/resources/bot_update.py index c59725e35..3172340e8 100755 --- a/recipes/recipe_modules/bot_update/resources/bot_update.py +++ b/recipes/recipe_modules/bot_update/resources/bot_update.py @@ -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, diff --git a/tests/bot_update_coverage_test.py b/tests/bot_update_coverage_test.py index f623e6daa..232e0061d 100755 --- a/tests/bot_update_coverage_test.py +++ b/tests/bot_update_coverage_test.py @@ -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__':