Skip to content

Commit be46cb5

Browse files
committed
Make deltas system correctly handle submodules in repository under test
The deltas system must use `git checkout --recurse_submodules` when checking out the base and head refs so the submodule is always at the ref corresponding to the superproject's ref.
1 parent 25febf3 commit be46cb5

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

compilesketches/compilesketches.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ def get_sketch_report(self, compilation_result):
813813
previous_compilation_result = self.compile_sketch(sketch_path=compilation_result.sketch)
814814

815815
# git checkout the head ref to return the repository to its previous state
816-
repository.git.checkout(original_git_ref)
816+
repository.git.checkout(original_git_ref, recurse_submodules=True)
817817

818818
previous_sizes = self.get_sizes_from_output(compilation_result=previous_compilation_result)
819819

@@ -940,11 +940,15 @@ def checkout_deltas_base_ref(self):
940940

941941
# git fetch the deltas base ref
942942
origin_remote = repository.remotes["origin"]
943-
origin_remote.fetch(refspec=self.deltas_base_ref, verbose=self.verbose, no_tags=True, prune=True,
944-
depth=1)
943+
origin_remote.fetch(refspec=self.deltas_base_ref,
944+
verbose=self.verbose,
945+
no_tags=True,
946+
prune=True,
947+
depth=1,
948+
recurse_submodules=True)
945949

946950
# git checkout the deltas base ref
947-
repository.git.checkout(self.deltas_base_ref)
951+
repository.git.checkout(self.deltas_base_ref, recurse_submodules=True)
948952

949953
def get_sizes_report(self, current_sizes, previous_sizes):
950954
"""Return a list containing all memory usage data assembled.

compilesketches/tests/test_compilesketches.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ def checkout(self):
12671267
git.Repo.assert_called_once_with(path=os.environ["GITHUB_WORKSPACE"])
12681268
compile_sketches.checkout_deltas_base_ref.assert_called_once()
12691269
compile_sketches.compile_sketch.assert_called_once_with(compile_sketches, sketch_path=compilation_result.sketch)
1270-
Repo.checkout.assert_called_once_with(original_git_ref)
1270+
Repo.checkout.assert_called_once_with(original_git_ref, recurse_submodules=True)
12711271
get_sizes_from_output_calls.append(
12721272
unittest.mock.call(compile_sketches, compilation_result=previous_compilation_result))
12731273
expected_previous_sizes = sizes_list[1]
@@ -1549,9 +1549,11 @@ def checkout(self):
15491549
git.Repo.assert_called_once_with(path=os.environ["GITHUB_WORKSPACE"])
15501550
Repo.fetch.assert_called_once_with(refspec=deltas_base_ref,
15511551
verbose=compile_sketches.verbose,
1552-
no_tags=True, prune=True,
1553-
depth=1)
1554-
Repo.checkout.assert_called_once_with(deltas_base_ref)
1552+
no_tags=True,
1553+
prune=True,
1554+
depth=1,
1555+
recurse_submodules=True)
1556+
Repo.checkout.assert_called_once_with(deltas_base_ref, recurse_submodules=True)
15551557

15561558

15571559
def test_get_sizes_report(mocker):

0 commit comments

Comments
 (0)