diff options
author | Raman Tenneti <rtenneti@google.com> | 2021-06-28 19:21:38 -0700 |
---|---|---|
committer | Raman Tenneti <rtenneti@google.com> | 2021-06-29 16:46:07 +0000 |
commit | 1da6f30579ca6aa698becc0daaf71eaa86237fc8 (patch) | |
tree | 52a4e505a858b4bb41d6a23aec6859b4fd58f17f | |
parent | 784e16f3aa941ca3564d823cc686017a161621a1 (diff) | |
download | git-repo-1da6f30579ca6aa698becc0daaf71eaa86237fc8.tar.gz |
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 <delphij@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Raman Tenneti <rtenneti@google.com>
-rw-r--r-- | git_superproject.py | 3 | ||||
-rw-r--r-- | 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): | |||
298 | path = project.relpath | 298 | path = project.relpath |
299 | if not path: | 299 | if not path: |
300 | return True | 300 | return True |
301 | # Skip the project with revisionId. | ||
302 | if project.revisionId: | ||
303 | return True | ||
301 | # Skip the project if it comes from the local manifest. | 304 | # Skip the project if it comes from the local manifest. |
302 | return any(s.startswith(LOCAL_MANIFEST_GROUP_PREFIX) for s in project.groups) | 305 | return any(s.startswith(LOCAL_MANIFEST_GROUP_PREFIX) for s in project.groups) |
303 | 306 | ||
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): | |||
294 | self.git_event_log) | 294 | self.git_event_log) |
295 | self.assertEqual(len(self._superproject._manifest.projects), 2) | 295 | self.assertEqual(len(self._superproject._manifest.projects), 2) |
296 | projects = self._superproject._manifest.projects | 296 | projects = self._superproject._manifest.projects |
297 | data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00' | 297 | data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00') |
298 | '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tbootable/recovery\x00') | ||
299 | with mock.patch.object(self._superproject, '_Init', return_value=True): | 298 | with mock.patch.object(self._superproject, '_Init', return_value=True): |
300 | with mock.patch.object(self._superproject, '_Fetch', return_value=True): | 299 | with mock.patch.object(self._superproject, '_Fetch', return_value=True): |
301 | with mock.patch.object(self._superproject, | 300 | with mock.patch.object(self._superproject, |
@@ -324,6 +323,54 @@ class SuperprojectTestCase(unittest.TestCase): | |||
324 | '<superproject name="superproject"/>' | 323 | '<superproject name="superproject"/>' |
325 | '</manifest>') | 324 | '</manifest>') |
326 | 325 | ||
326 | def test_superproject_update_project_revision_id_with_pinned_manifest(self): | ||
327 | """Test update of commit ids of a pinned manifest.""" | ||
328 | manifest = self.getXmlManifest(""" | ||
329 | <manifest> | ||
330 | <remote name="default-remote" fetch="http://localhost" /> | ||
331 | <default remote="default-remote" revision="refs/heads/main" /> | ||
332 | <superproject name="superproject"/> | ||
333 | <project path="vendor/x" name="platform/vendor/x" revision="" /> | ||
334 | <project path="vendor/y" name="platform/vendor/y" | ||
335 | revision="52d3c9f7c107839ece2319d077de0cd922aa9d8f" /> | ||
336 | <project path="art" name="platform/art" groups="notdefault,platform-""" + self.platform + """ | ||
337 | " /></manifest> | ||
338 | """) | ||
339 | self.maxDiff = None | ||
340 | self._superproject = git_superproject.Superproject(manifest, self.repodir, | ||
341 | self.git_event_log) | ||
342 | self.assertEqual(len(self._superproject._manifest.projects), 3) | ||
343 | projects = self._superproject._manifest.projects | ||
344 | data = ('160000 commit 2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea\tart\x00' | ||
345 | '160000 commit e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06\tvendor/x\x00') | ||
346 | with mock.patch.object(self._superproject, '_Init', return_value=True): | ||
347 | with mock.patch.object(self._superproject, '_Fetch', return_value=True): | ||
348 | with mock.patch.object(self._superproject, | ||
349 | '_LsTree', | ||
350 | return_value=data): | ||
351 | # Create temporary directory so that it can write the file. | ||
352 | os.mkdir(self._superproject._superproject_path) | ||
353 | update_result = self._superproject.UpdateProjectsRevisionId(projects) | ||
354 | self.assertIsNotNone(update_result.manifest_path) | ||
355 | self.assertFalse(update_result.fatal) | ||
356 | with open(update_result.manifest_path, 'r') as fp: | ||
357 | manifest_xml_data = fp.read() | ||
358 | # Verify platform/vendor/x's project revision hasn't changed. | ||
359 | self.assertEqual( | ||
360 | sort_attributes(manifest_xml_data), | ||
361 | '<?xml version="1.0" ?><manifest>' | ||
362 | '<remote fetch="http://localhost" name="default-remote"/>' | ||
363 | '<default remote="default-remote" revision="refs/heads/main"/>' | ||
364 | '<project groups="notdefault,platform-' + self.platform + '" ' | ||
365 | 'name="platform/art" path="art" ' | ||
366 | 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>' | ||
367 | '<project name="platform/vendor/x" path="vendor/x" ' | ||
368 | 'revision="e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06"/>' | ||
369 | '<project name="platform/vendor/y" path="vendor/y" ' | ||
370 | 'revision="52d3c9f7c107839ece2319d077de0cd922aa9d8f"/>' | ||
371 | '<superproject name="superproject"/>' | ||
372 | '</manifest>') | ||
373 | |||
327 | 374 | ||
328 | if __name__ == '__main__': | 375 | if __name__ == '__main__': |
329 | unittest.main() | 376 | unittest.main() |