Skip to content

Commit 0f2a4f3

Browse files
committed
Prevent unnecessary submodule fetches
Signed-off-by: Bence Szépkúti <[email protected]>
1 parent 8d95062 commit 0f2a4f3

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

scripts/abi_check.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,24 @@ def _update_git_submodules(self, git_worktree_path, version):
204204
stderr=subprocess.STDOUT
205205
)
206206
self.log.debug(submodule_output.decode("utf-8"))
207-
update_output = subprocess.check_output(
208-
[self.git_command, "submodule", "update", "--init", '--recursive'],
209-
cwd=git_worktree_path,
210-
stderr=subprocess.STDOUT
211-
)
207+
208+
try:
209+
# Try to update the submodules using local commits
210+
# (Git will sometimes insist on fetching the remote without --no-fetch if the submodules are shallow clones)
211+
update_output = subprocess.check_output(
212+
[self.git_command, "submodule", "update", "--init", '--recursive', '--no-fetch'],
213+
cwd=git_worktree_path,
214+
stderr=subprocess.STDOUT
215+
)
216+
except subprocess.CalledProcessError as err:
217+
self.log.debug(err.stdout.decode("utf-8"))
218+
219+
# Checkout with --no-fetch failed, falling back to fetching from origin
220+
update_output = subprocess.check_output(
221+
[self.git_command, "submodule", "update", "--init", '--recursive'],
222+
cwd=git_worktree_path,
223+
stderr=subprocess.STDOUT
224+
)
212225
self.log.debug(update_output.decode("utf-8"))
213226
if not (os.path.exists(os.path.join(git_worktree_path, "crypto"))
214227
and version.crypto_revision):

0 commit comments

Comments
 (0)