@@ -41,7 +41,14 @@ def sync_repo(repo: str) -> bool:
4141 os .chdir (_PYTORCH_DIR if repo == _PYTORCH_REPO else _VISION_DIR if repo ==
4242 _VISION_REPO else _PTXLA_DIR )
4343
44- # It's unsafe to sync the repo if there are uncommited changes or untracked files.
44+ # Update the submodules to avoid outdated submodules showing up as uncommited
45+ # changes.
46+ if os .system ('git submodule update --init --recursive' ) != 0 :
47+ logger .error (f'Failed to update submodules in the { repo } repo.' )
48+ return False
49+
50+ # It's unsafe to sync the repo if there are uncommited changes or untracked
51+ # files.
4552 uncommitted_changes = os .popen ('git status --porcelain' ).read ().strip ()
4653 if uncommitted_changes :
4754 logger .error (
@@ -74,6 +81,13 @@ def sync_default_branch() -> bool:
7481 f'Failed to checkout the { default_branch } branch of the { repo } repo.' )
7582 return False
7683
84+ # Update the submodules to avoid outdated submodules showing up as
85+ # uncommited changes. We need to do this to be safe whenever we switch
86+ # to a new branch.
87+ if os .system ('git submodule update --init --recursive' ) != 0 :
88+ logger .error (f'Failed to update submodules in the { repo } repo.' )
89+ return False
90+
7791 # Make sure the remotes are set up correctly:
7892 #
7993 # - There must be an "origin" remote, pointing to where the local repo is
@@ -119,6 +133,12 @@ def sync_default_branch() -> bool:
119133 f'Failed to checkout the { orig_branch } branch of the { repo } repo.' )
120134 success = False
121135
136+ # Update the submodules to avoid outdated submodules showing up as uncommited
137+ # changes. We need to do this to be safe whenever we switch to a new branch.
138+ if os .system ('git submodule update --init --recursive' ) != 0 :
139+ logger .error (f'Failed to update submodules in the { repo } repo.' )
140+ return False
141+
122142 if success :
123143 logger .info (
124144 f'Successfully updated the default branch of the { repo } repo to match upstream.'
0 commit comments