Skip to content

Commit

Permalink
Add reference argument to submodule update --init invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
joschock committed Jul 2, 2024
1 parent ccfe4ef commit 6f75785
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions edk2toolext/environment/repo_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ def checkout(
"""
details = repo_details(abs_file_system_path)
with Repo(abs_file_system_path) as repo:
reference = None
if "ReferencePath" in dep and os.path.exists(dep["ReferencePath"]):
reference = Path(dep["ReferencePath"])

Check warning on line 393 in edk2toolext/environment/repo_resolver.py

View check run for this annotation

Codecov / codecov/patch

edk2toolext/environment/repo_resolver.py#L393

Added line #L393 was not covered by tests
if "Commit" in dep:
commit = dep["Commit"]
if update_ok or force:
Expand All @@ -397,7 +400,10 @@ def checkout(
except GitCommandError:
repo.git.fetch()
repo.git.checkout(commit)
repo.git.submodule("update", "--init", "--recursive")
if reference:
repo.git.submodule("update", "--init", "--recursive", "--reference", reference.as_posix())

Check warning on line 404 in edk2toolext/environment/repo_resolver.py

View check run for this annotation

Codecov / codecov/patch

edk2toolext/environment/repo_resolver.py#L404

Added line #L404 was not covered by tests
else:
repo.git.submodule("update", "--init", "--recursive")
else:
head = details["Head"]
if commit in [head["HexSha"], head["HexShaShort"]]:
Expand Down Expand Up @@ -427,7 +433,10 @@ def checkout(
repo.remotes.origin.config_writer.set_value("fetch", refspec).release()
repo.git.fetch()
repo.git.checkout(branch)
repo.git.submodule("update", "--init", "--recursive")
if reference:
repo.git.submodule("update", "--init", "--recursive", "--reference", reference.as_posix())

Check warning on line 437 in edk2toolext/environment/repo_resolver.py

View check run for this annotation

Codecov / codecov/patch

edk2toolext/environment/repo_resolver.py#L437

Added line #L437 was not covered by tests
else:
repo.git.submodule("update", "--init", "--recursive")
else:
if details["Branch"] == dep["Branch"]:
logger.debug(
Expand Down

0 comments on commit 6f75785

Please sign in to comment.