diff --git a/tools/repo_setup.py b/tools/repo_setup.py index 8f67fe9a8..317419351 100644 --- a/tools/repo_setup.py +++ b/tools/repo_setup.py @@ -173,6 +173,7 @@ def remove_repo(path): exec_count = 0 while exec_count < 3: + repo_cloned = False # Change the current working directory to the script directory os.chdir(self.script_dir) full_repo_path = os.path.join(self.script_dir, _path) @@ -186,6 +187,7 @@ def remove_repo(path): if result.returncode != 0: print_error(f"Git clone failed on {_path}") return + repo_cloned = True else: print_color(f"Updating submodule {_path}", BLUE) @@ -219,23 +221,24 @@ def remove_repo(path): return stash_applied = False - status_output = subprocess.check_output( - ["git", "status", "--porcelain"] - ).decode("utf-8") - if status_output: - _result = self.run_command( - [ - "git", - "stash", - "push", - "-m", - '"STASHED BY REPO_SETUP.PY"', - "--include-untracked", - ], - _path, - ) - if _result.returncode == 0: - stash_applied = True + if not repo_cloned: + status_output = subprocess.check_output( + ["git", "status", "--porcelain"] + ).decode("utf-8") + if status_output: + _result = self.run_command( + [ + "git", + "stash", + "push", + "-m", + '"STASHED BY REPO_SETUP.PY"', + "--include-untracked", + ], + _path, + ) + if _result.returncode == 0: + stash_applied = True fetch_command = ["git", "fetch", "origin"] # if target_type == "tag":