From 1da6f30579ca6aa698becc0daaf71eaa86237fc8 Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Mon, 28 Jun 2021 19:21:38 -0700 Subject: [PATCH] superproject - don't update the commit ids of projects that have revisionId. Pinned manifests and release manifest have revisionId set for all projects. For such projects don't update the commit ids. Tested the code with the following commands. $ ./run_tests -v $ repo_dev sync --use-superproject -j8 $ repo_dev sync -n -c -j32 -m $(pwd)/manifest_7482982.xml Bug: [google internal] b/191995372 Change-Id: I4681135b1d15f4a63527b6f0356d76ec842485d6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/310582 Reviewed-by: Xin Li Reviewed-by: Mike Frysinger Tested-by: Raman Tenneti --- git_superproject.py | 3 ++ tests/test_git_superproject.py | 51 ++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/git_superproject.py b/git_superproject.py index 8f1e04d6..0c477060 100644 --- a/git_superproject.py +++ b/git_superproject.py @@ -298,6 +298,9 @@ class Superproject(object): path = project.relpath if not path: return True + # Skip the project with revisionId. + if project.revisionId: + return True # Skip the project if it comes from the local manifest. return any(s.startswith(LOCAL_MANIFEST_GROUP_PREFIX) for s in project.groups) diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index d612f4e7..c3f88531 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py @@ -294,8 +294,7 @@ class SuperprojectTestCase(unittest.TestCase): self.git_event_log) 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') + data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\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, @@ -324,6 +323,54 @@ class SuperprojectTestCase(unittest.TestCase): '' '') + def test_superproject_update_project_revision_id_with_pinned_manifest(self): + """Test update of commit ids of a pinned manifest.""" + manifest = self.getXmlManifest(""" + + + + + + + +""") + self.maxDiff = None + self._superproject = git_superproject.Superproject(manifest, self.repodir, + self.git_event_log) + self.assertEqual(len(self._superproject._manifest.projects), 3) + projects = self._superproject._manifest.projects + data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00' + '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tvendor/x\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) + update_result = self._superproject.UpdateProjectsRevisionId(projects) + self.assertIsNotNone(update_result.manifest_path) + self.assertFalse(update_result.fatal) + with open(update_result.manifest_path, 'r') as fp: + manifest_xml_data = fp.read() + # Verify platform/vendor/x's project revision hasn't changed. + self.assertEqual( + sort_attributes(manifest_xml_data), + '' + '' + '' + '' + '' + '' + '' + '') + if __name__ == '__main__': unittest.main()