From feb28914bd17aacc2d251516e504a33f991f86c4 Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Sun, 2 May 2021 19:47:29 -0700 Subject: superproject: Don't update the commit ids of projects if remote is different. 1) Skip setting the revision id (commit id) for the projects whose remote doesn't match superproject's remote. 2) exp-superproject/superproject_override.xml includes local_manfiest's projects. When we load this XML, don't reload projects from local.xml (otherwise we will get duplicate projects errors). Tested the code with the following commands. $ ./run_tests -v + Test with local.xml $ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --use-superproject --partial-clone --clone-filter=blob:limit=10M && mkdir -p .repo/local_manifests && (gcertstatus -quiet=true || gcert) && ln -s /google/src/head/depot/google3/wireless/android/build_tools/aosp/manifests/mirror-aosp-master-with-vendor/local.xml .repo/local_manifests/local.xml $ repo_dev sync -c -j8 + Test without local.xml $ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject $ repo_dev sync -c -j8 Bug: [google internal] b/186395810 Change-Id: I4e9d4ac2d94a9fc0cef0ccd787b6310758009e86 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/304882 Tested-by: Raman Tenneti Reviewed-by: Mike Frysinger --- tests/test_git_superproject.py | 70 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 13 deletions(-) (limited to 'tests/test_git_superproject.py') diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index 9550949b..5c1455f5 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py @@ -141,12 +141,12 @@ class SuperprojectTestCase(unittest.TestCase): manifest_xml = fp.read() self.assertEqual( manifest_xml, - '' + - '' + - '' + - '' + - '' + + '' + '' + '' + '' + '' '') def test_superproject_update_project_revision_id(self): @@ -168,13 +168,57 @@ class SuperprojectTestCase(unittest.TestCase): manifest_xml = fp.read() self.assertEqual( manifest_xml, - '' + - '' + - '' + - '' + - '' + + '' + '' + '' + '' + '' + '') + + 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( + manifest_xml, + '' + '' + '' + '' + '' + '' + '' '') -- cgit v1.2.3-54-g00ecf