project: Do not exit early on --standalone-manifest.

After we successfully download the standalone manifest file, we cannot
exit early.

Bug: https://bugs.chromium.org/p/gerrit/issues/detail?id=15861
Change-Id: Ic47c9f7e9921851f94c6f24fd82b896eff524037
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/335974
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Tested-by: LaMont Jones <lamontjones@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
LaMont Jones 2022-04-27 17:34:42 +00:00
parent 0de4fc3001
commit 0165e20fcc

View File

@ -3710,46 +3710,45 @@ class ManifestProject(MetaProject):
if use_superproject is not None: if use_superproject is not None:
self.config.SetBoolean('repo.superproject', use_superproject) self.config.SetBoolean('repo.superproject', use_superproject)
if standalone_manifest: if not standalone_manifest:
if is_new: if not self.Sync_NetworkHalf(
manifest_name = 'default.xml' is_new=is_new, quiet=not verbose, verbose=verbose,
manifest_data = fetch.fetch_file(manifest_url, verbose=verbose) clone_bundle=clone_bundle, current_branch_only=current_branch_only,
dest = os.path.join(self.worktree, manifest_name) tags=tags, submodules=submodules, clone_filter=clone_filter,
os.makedirs(os.path.dirname(dest), exist_ok=True) partial_clone_exclude=self.manifest.PartialCloneExclude):
with open(dest, 'wb') as f: r = self.GetRemote(self.remote.name)
f.write(manifest_data) print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr)
return
if not self.Sync_NetworkHalf(is_new=is_new, quiet=not verbose, verbose=verbose, # Better delete the manifest git dir if we created it; otherwise next
clone_bundle=clone_bundle, # time (when user fixes problems) we won't go through the "is_new" logic.
current_branch_only=current_branch_only, if is_new:
tags=tags, submodules=submodules, platform_utils.rmtree(self.gitdir)
clone_filter=clone_filter,
partial_clone_exclude=self.manifest.PartialCloneExclude):
r = self.GetRemote(self.remote.name)
print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr)
# Better delete the manifest git dir if we created it; otherwise next
# time (when user fixes problems) we won't go through the "is_new" logic.
if is_new:
platform_utils.rmtree(self.gitdir)
return False
if manifest_branch:
self.MetaBranchSwitch(submodules=submodules)
syncbuf = SyncBuffer(self.config)
self.Sync_LocalHalf(syncbuf, submodules=submodules)
syncbuf.Finish()
if is_new or self.CurrentBranch is None:
if not self.StartBranch('default'):
print('fatal: cannot create default in manifest', file=sys.stderr)
return False return False
if not manifest_name: if manifest_branch:
print('fatal: manifest name (-m) is required.', file=sys.stderr) self.MetaBranchSwitch(submodules=submodules)
return False
syncbuf = SyncBuffer(self.config)
self.Sync_LocalHalf(syncbuf, submodules=submodules)
syncbuf.Finish()
if is_new or self.CurrentBranch is None:
if not self.StartBranch('default'):
print('fatal: cannot create default in manifest', file=sys.stderr)
return False
if not manifest_name:
print('fatal: manifest name (-m) is required.', file=sys.stderr)
return False
elif is_new:
# This is a new standalone manifest.
manifest_name = 'default.xml'
manifest_data = fetch.fetch_file(manifest_url, verbose=verbose)
dest = os.path.join(self.worktree, manifest_name)
os.makedirs(os.path.dirname(dest), exist_ok=True)
with open(dest, 'wb') as f:
f.write(manifest_data)
try: try:
self.manifest.Link(manifest_name) self.manifest.Link(manifest_name)