superproject: skip updating commit ids if remote's fetchUrl don't match.

Tested the code with the following commands.

$ ./run_tests -v

+ Test with local.xml
  $ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --use-superproject --partial-clone --clone-filter=blob:limit=10M && mkdir -p .repo/local_manifests && (gcertstatus -quiet=true || gcert) && ln -s /google/src/head/depot/google3/wireless/android/build_tools/aosp/manifests/mirror-aosp-master-with-vendor/local.xml  .repo/local_manifests/local.xml

  $ repo_dev sync -c -j8

+ Test without local.xml
  $ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject
  $ repo_dev sync -c -j8

Bug: [google internal] b/186395810
Change-Id: Id618113a91c12bcb90a30a3c23d3d6842bcb49e1
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/304942
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Raman Tenneti <rtenneti@google.com>
This commit is contained in:
Raman Tenneti 2021-05-02 22:55:26 -07:00
parent d68ed63328
commit 5a41b0be01

View File

@ -262,7 +262,7 @@ class Superproject(object):
return None
projects_missing_commit_ids = []
superproject_remote_name = self._manifest.superproject['remote'].name
superproject_fetchUrl = self._manifest.superproject['remote'].fetchUrl
for project in projects:
path = project.relpath
if not path:
@ -274,7 +274,7 @@ class Superproject(object):
# superproject's remote. Until superproject, supports multiple remotes,
# don't update the commit ids of remotes that don't match superproject's
# remote.
if project.remote.name != superproject_remote_name:
if project.remote.fetchUrl != superproject_fetchUrl:
continue
commit_id = commit_ids.get(path)
if commit_id: