Skip to content

Commit

Permalink
Fix stash on repo clone (#971)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldsdias authored Jun 17, 2024
1 parent ee0ae09 commit 700f51a
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions tools/repo_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 700f51a

Please sign in to comment.