Bug 1634560 - Fix fetch-config for git repos with submodules. r=dmajor

There are cases where --recurse-submodules breaks things (e.g. when
newer versions of the repository remove a submodule). So don't
recurse-submodules at all at clone or checkout time, but instead
initialize and update submodules after the checkout.

Also don't checkout at clone time, because it's redundant with the
checkout, and we only really trust the explicit checkout anyways, so
it's better to not checkout during the clone.

Differential Revision: https://phabricator.services.mozilla.com/D73353
This commit is contained in:
Mike Hommey 2020-05-02 06:18:33 +00:00
parent 43a2e97c21
commit a760600961

View File

@ -501,10 +501,13 @@ def git_checkout_archive(dest_path: pathlib.Path, repo: str, commit: str,
# to initiate a clone. Since the commit-ish may not refer to a ref, we
# simply perform a full clone followed by a checkout.
print('cloning %s to %s' % (repo, git_dir))
subprocess.run(['git', 'clone', '--recurse-submodules', repo, str(git_dir)],
subprocess.run(['git', 'clone', '-n', repo, str(git_dir)],
check=True)
subprocess.run(['git', 'checkout', '--recurse-submodules', commit],
subprocess.run(['git', 'checkout', commit],
cwd=str(git_dir), check=True)
subprocess.run(['git', 'submodule', 'update', '--init'],
cwd=str(git_dir), check=True)
print('creating archive %s of commit %s' % (dest_path, commit))