From 50c91ecf4f313a223bc6737d047fc32d665db0fd Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Tue, 8 Jun 2021 10:46:51 -0700 Subject: [PATCH] superproject: revert not updating commit ids if remote is different. superproject supports multiple remotes. Get all commit ids from superproject for all projects that are in the manifest. $ ./run_tests -v Bug: [google internal] b/186395810 Change-Id: I6edce3918853a7a3a65aec5528e6a43a544eff53 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/308862 Tested-by: Raman Tenneti Reviewed-by: Jonathan Nieder Reviewed-by: Mike Frysinger --- git_superproject.py | 10 -------- tests/test_git_superproject.py | 45 ---------------------------------- 2 files changed, 55 deletions(-) diff --git a/git_superproject.py b/git_superproject.py index f7ccd574..dad6a3de 100644 --- a/git_superproject.py +++ b/git_superproject.py @@ -264,20 +264,10 @@ class Superproject(object): return None projects_missing_commit_ids = [] - superproject_fetchUrl = self._manifest.superproject['remote'].fetchUrl for project in projects: path = project.relpath if not path: continue - # Some manifests that pull projects from the "chromium" GoB - # (remote="chromium"), and have a private manifest that pulls projects - # from both the chromium GoB and "chrome-internal" GoB (remote="chrome"). - # For such projects, one of the remotes will be different from - # superproject's remote. Until superproject, supports multiple remotes, - # don't update the commit ids of remotes that don't match superproject's - # remote. - if project.remote.fetchUrl != superproject_fetchUrl: - continue commit_id = commit_ids.get(path) if commit_id: project.SetRevisionId(commit_id) diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index b1ae3576..707f7dab 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py @@ -178,51 +178,6 @@ class SuperprojectTestCase(unittest.TestCase): '' '') - def test_superproject_update_project_revision_id_with_different_remotes(self): - """Test update of commit ids of a manifest with mutiple remotes.""" - manifest = self.getXmlManifest(""" - - - - - - - -""") - self.maxDiff = None - self._superproject = git_superproject.Superproject(manifest, self.repodir) - self.assertEqual(len(self._superproject._manifest.projects), 2) - projects = self._superproject._manifest.projects - data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00' - '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tbootable/recovery\x00') - with mock.patch.object(self._superproject, '_Init', return_value=True): - with mock.patch.object(self._superproject, '_Fetch', return_value=True): - with mock.patch.object(self._superproject, - '_LsTree', - return_value=data): - # Create temporary directory so that it can write the file. - os.mkdir(self._superproject._superproject_path) - manifest_path = self._superproject.UpdateProjectsRevisionId(projects) - self.assertIsNotNone(manifest_path) - with open(manifest_path, 'r') as fp: - manifest_xml = fp.read() - self.assertEqual( - sort_attributes(manifest_xml), - '' - '' - '' - '' - '' - '' - '' - '') - if __name__ == '__main__': unittest.main()