diff options
author | Xin Li <delphij@google.com> | 2021-06-29 21:42:34 +0000 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2021-06-30 15:31:15 +0000 |
commit | 0e776a5837d08d58cedd1d9e4288ed7db349749c (patch) | |
tree | 28c7c3898923413f0ca6b141671ee811303cfbc5 /tests | |
parent | 1da6f30579ca6aa698becc0daaf71eaa86237fc8 (diff) | |
download | git-repo-0e776a5837d08d58cedd1d9e4288ed7db349749c.tar.gz |
Fix an issue when syncing with --use-superproject and clone bundles.
It is possible that a clone bundle contained the object referenced by
the branch in the manifest and in the superproject, but not the branch
itself (for example, the branch may be newly created from an existing
branch, or is not vislble to the user downloading the clone bundle).
When --use-superproject is enabled, because we are overriding
revisionExpr with the SHA1 revision provided by the superproject, the
verification step would succeed, but because the expected branch do not
exist, it would confuse git-repo at a later time, as it is expecting the
remote branch to exist in the local clone.
In project.py, fix this by making SetRevisionId() to always remember
the actual branch name and verify it in _CheckForImmutableRevision()
so that we only skip the fetch step when both objects exists locally.
Bug: [google internal] b/191974277
Change-Id: I49d3ca0667f524c8c45f416492faf95b1dd822fb
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/310802
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Xin Li <delphij@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_git_superproject.py | 12 | ||||
-rw-r--r-- | tests/test_manifest_xml.py | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index c3f88531..6ff81843 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py | |||
@@ -213,7 +213,7 @@ class SuperprojectTestCase(unittest.TestCase): | |||
213 | '<remote fetch="http://localhost" name="default-remote"/>' | 213 | '<remote fetch="http://localhost" name="default-remote"/>' |
214 | '<default remote="default-remote" revision="refs/heads/main"/>' | 214 | '<default remote="default-remote" revision="refs/heads/main"/>' |
215 | '<project groups="notdefault,platform-' + self.platform + '" ' | 215 | '<project groups="notdefault,platform-' + self.platform + '" ' |
216 | 'name="platform/art" path="art" revision="ABCDEF"/>' | 216 | 'name="platform/art" path="art" revision="ABCDEF" upstream="refs/heads/main"/>' |
217 | '<superproject name="superproject"/>' | 217 | '<superproject name="superproject"/>' |
218 | '</manifest>') | 218 | '</manifest>') |
219 | 219 | ||
@@ -242,7 +242,7 @@ class SuperprojectTestCase(unittest.TestCase): | |||
242 | '<default remote="default-remote" revision="refs/heads/main"/>' | 242 | '<default remote="default-remote" revision="refs/heads/main"/>' |
243 | '<project groups="notdefault,platform-' + self.platform + '" ' | 243 | '<project groups="notdefault,platform-' + self.platform + '" ' |
244 | 'name="platform/art" path="art" ' | 244 | 'name="platform/art" path="art" ' |
245 | 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>' | 245 | 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea" upstream="refs/heads/main"/>' |
246 | '<superproject name="superproject"/>' | 246 | '<superproject name="superproject"/>' |
247 | '</manifest>') | 247 | '</manifest>') |
248 | 248 | ||
@@ -271,7 +271,7 @@ class SuperprojectTestCase(unittest.TestCase): | |||
271 | '<?xml version="1.0" ?><manifest>' | 271 | '<?xml version="1.0" ?><manifest>' |
272 | '<remote fetch="http://localhost" name="default-remote"/>' | 272 | '<remote fetch="http://localhost" name="default-remote"/>' |
273 | '<default remote="default-remote" revision="refs/heads/main"/>' | 273 | '<default remote="default-remote" revision="refs/heads/main"/>' |
274 | '<project name="test-name" revision="ABCDEF"/>' | 274 | '<project name="test-name" revision="ABCDEF" upstream="refs/heads/main"/>' |
275 | '</manifest>') | 275 | '</manifest>') |
276 | 276 | ||
277 | def test_superproject_update_project_revision_id_from_local_manifest_group(self): | 277 | def test_superproject_update_project_revision_id_from_local_manifest_group(self): |
@@ -316,7 +316,7 @@ class SuperprojectTestCase(unittest.TestCase): | |||
316 | '<default remote="default-remote" revision="refs/heads/main"/>' | 316 | '<default remote="default-remote" revision="refs/heads/main"/>' |
317 | '<project groups="notdefault,platform-' + self.platform + '" ' | 317 | '<project groups="notdefault,platform-' + self.platform + '" ' |
318 | 'name="platform/art" path="art" ' | 318 | 'name="platform/art" path="art" ' |
319 | 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>' | 319 | 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea" upstream="refs/heads/main"/>' |
320 | '<project clone-depth="1" groups="' + local_group + '" ' | 320 | '<project clone-depth="1" groups="' + local_group + '" ' |
321 | 'name="platform/vendor/x" path="vendor/x" remote="goog" ' | 321 | 'name="platform/vendor/x" path="vendor/x" remote="goog" ' |
322 | 'revision="master-with-vendor"/>' | 322 | 'revision="master-with-vendor"/>' |
@@ -363,9 +363,9 @@ class SuperprojectTestCase(unittest.TestCase): | |||
363 | '<default remote="default-remote" revision="refs/heads/main"/>' | 363 | '<default remote="default-remote" revision="refs/heads/main"/>' |
364 | '<project groups="notdefault,platform-' + self.platform + '" ' | 364 | '<project groups="notdefault,platform-' + self.platform + '" ' |
365 | 'name="platform/art" path="art" ' | 365 | 'name="platform/art" path="art" ' |
366 | 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>' | 366 | 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea" upstream="refs/heads/main"/>' |
367 | '<project name="platform/vendor/x" path="vendor/x" ' | 367 | '<project name="platform/vendor/x" path="vendor/x" ' |
368 | 'revision="e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06"/>' | 368 | 'revision="e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06" upstream="refs/heads/main"/>' |
369 | '<project name="platform/vendor/y" path="vendor/y" ' | 369 | '<project name="platform/vendor/y" path="vendor/y" ' |
370 | 'revision="52d3c9f7c107839ece2319d077de0cd922aa9d8f"/>' | 370 | 'revision="52d3c9f7c107839ece2319d077de0cd922aa9d8f"/>' |
371 | '<superproject name="superproject"/>' | 371 | '<superproject name="superproject"/>' |
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 2a16900a..55468b51 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
@@ -437,7 +437,7 @@ class ProjectElementTests(ManifestParseTestCase): | |||
437 | '<?xml version="1.0" ?><manifest>' | 437 | '<?xml version="1.0" ?><manifest>' |
438 | '<remote fetch="http://localhost" name="default-remote"/>' | 438 | '<remote fetch="http://localhost" name="default-remote"/>' |
439 | '<default remote="default-remote" revision="refs/heads/main"/>' | 439 | '<default remote="default-remote" revision="refs/heads/main"/>' |
440 | '<project name="test-name" revision="ABCDEF"/>' | 440 | '<project name="test-name" revision="ABCDEF" upstream="refs/heads/main"/>' |
441 | '</manifest>') | 441 | '</manifest>') |
442 | 442 | ||
443 | def test_trailing_slash(self): | 443 | def test_trailing_slash(self): |