mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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>
This commit is contained in:
parent
1da6f30579
commit
0e776a5837
@ -1216,7 +1216,7 @@ class Project(object):
|
|||||||
(self.revisionExpr, self.name))
|
(self.revisionExpr, self.name))
|
||||||
|
|
||||||
def SetRevisionId(self, revisionId):
|
def SetRevisionId(self, revisionId):
|
||||||
if self.clone_depth or self.manifest.manifestProject.config.GetString('repo.depth'):
|
if self.revisionExpr:
|
||||||
self.upstream = self.revisionExpr
|
self.upstream = self.revisionExpr
|
||||||
|
|
||||||
self.revisionId = revisionId
|
self.revisionId = revisionId
|
||||||
@ -1967,6 +1967,10 @@ class Project(object):
|
|||||||
# throws an error.
|
# throws an error.
|
||||||
self.bare_git.rev_list('-1', '--missing=allow-any',
|
self.bare_git.rev_list('-1', '--missing=allow-any',
|
||||||
'%s^0' % self.revisionExpr, '--')
|
'%s^0' % self.revisionExpr, '--')
|
||||||
|
if self.upstream:
|
||||||
|
rev = self.GetRemote(self.remote.name).ToLocal(self.upstream)
|
||||||
|
self.bare_git.rev_list('-1', '--missing=allow-any',
|
||||||
|
'%s^0' % rev, '--')
|
||||||
return True
|
return True
|
||||||
except GitError:
|
except GitError:
|
||||||
# There is no such persistent revision. We have to fetch it.
|
# There is no such persistent revision. We have to fetch it.
|
||||||
|
@ -213,7 +213,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
'<remote fetch="http://localhost" name="default-remote"/>'
|
'<remote fetch="http://localhost" name="default-remote"/>'
|
||||||
'<default remote="default-remote" revision="refs/heads/main"/>'
|
'<default remote="default-remote" revision="refs/heads/main"/>'
|
||||||
'<project groups="notdefault,platform-' + self.platform + '" '
|
'<project groups="notdefault,platform-' + self.platform + '" '
|
||||||
'name="platform/art" path="art" revision="ABCDEF"/>'
|
'name="platform/art" path="art" revision="ABCDEF" upstream="refs/heads/main"/>'
|
||||||
'<superproject name="superproject"/>'
|
'<superproject name="superproject"/>'
|
||||||
'</manifest>')
|
'</manifest>')
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
'<default remote="default-remote" revision="refs/heads/main"/>'
|
'<default remote="default-remote" revision="refs/heads/main"/>'
|
||||||
'<project groups="notdefault,platform-' + self.platform + '" '
|
'<project groups="notdefault,platform-' + self.platform + '" '
|
||||||
'name="platform/art" path="art" '
|
'name="platform/art" path="art" '
|
||||||
'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>'
|
'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea" upstream="refs/heads/main"/>'
|
||||||
'<superproject name="superproject"/>'
|
'<superproject name="superproject"/>'
|
||||||
'</manifest>')
|
'</manifest>')
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
'<remote fetch="http://localhost" name="default-remote"/>'
|
'<remote fetch="http://localhost" name="default-remote"/>'
|
||||||
'<default remote="default-remote" revision="refs/heads/main"/>'
|
'<default remote="default-remote" revision="refs/heads/main"/>'
|
||||||
'<project name="test-name" revision="ABCDEF"/>'
|
'<project name="test-name" revision="ABCDEF" upstream="refs/heads/main"/>'
|
||||||
'</manifest>')
|
'</manifest>')
|
||||||
|
|
||||||
def test_superproject_update_project_revision_id_from_local_manifest_group(self):
|
def test_superproject_update_project_revision_id_from_local_manifest_group(self):
|
||||||
@ -316,7 +316,7 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
'<default remote="default-remote" revision="refs/heads/main"/>'
|
'<default remote="default-remote" revision="refs/heads/main"/>'
|
||||||
'<project groups="notdefault,platform-' + self.platform + '" '
|
'<project groups="notdefault,platform-' + self.platform + '" '
|
||||||
'name="platform/art" path="art" '
|
'name="platform/art" path="art" '
|
||||||
'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>'
|
'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea" upstream="refs/heads/main"/>'
|
||||||
'<project clone-depth="1" groups="' + local_group + '" '
|
'<project clone-depth="1" groups="' + local_group + '" '
|
||||||
'name="platform/vendor/x" path="vendor/x" remote="goog" '
|
'name="platform/vendor/x" path="vendor/x" remote="goog" '
|
||||||
'revision="master-with-vendor"/>'
|
'revision="master-with-vendor"/>'
|
||||||
@ -363,9 +363,9 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
'<default remote="default-remote" revision="refs/heads/main"/>'
|
'<default remote="default-remote" revision="refs/heads/main"/>'
|
||||||
'<project groups="notdefault,platform-' + self.platform + '" '
|
'<project groups="notdefault,platform-' + self.platform + '" '
|
||||||
'name="platform/art" path="art" '
|
'name="platform/art" path="art" '
|
||||||
'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>'
|
'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea" upstream="refs/heads/main"/>'
|
||||||
'<project name="platform/vendor/x" path="vendor/x" '
|
'<project name="platform/vendor/x" path="vendor/x" '
|
||||||
'revision="e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06"/>'
|
'revision="e9d25da64d8d365dbba7c8ee00fe8c4473fe9a06" upstream="refs/heads/main"/>'
|
||||||
'<project name="platform/vendor/y" path="vendor/y" '
|
'<project name="platform/vendor/y" path="vendor/y" '
|
||||||
'revision="52d3c9f7c107839ece2319d077de0cd922aa9d8f"/>'
|
'revision="52d3c9f7c107839ece2319d077de0cd922aa9d8f"/>'
|
||||||
'<superproject name="superproject"/>'
|
'<superproject name="superproject"/>'
|
||||||
|
@ -437,7 +437,7 @@ class ProjectElementTests(ManifestParseTestCase):
|
|||||||
'<?xml version="1.0" ?><manifest>'
|
'<?xml version="1.0" ?><manifest>'
|
||||||
'<remote fetch="http://localhost" name="default-remote"/>'
|
'<remote fetch="http://localhost" name="default-remote"/>'
|
||||||
'<default remote="default-remote" revision="refs/heads/main"/>'
|
'<default remote="default-remote" revision="refs/heads/main"/>'
|
||||||
'<project name="test-name" revision="ABCDEF"/>'
|
'<project name="test-name" revision="ABCDEF" upstream="refs/heads/main"/>'
|
||||||
'</manifest>')
|
'</manifest>')
|
||||||
|
|
||||||
def test_trailing_slash(self):
|
def test_trailing_slash(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user