Skip to content

Commit 6eeaf9b

Browse files
committed
Use subprocess.run() instead of os.system()
1 parent 9f37fa2 commit 6eeaf9b

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

docs/developer/release/release_utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,16 @@ def git_repo_exists_at_path(repo_root: Path) -> bool:
249249
def push_changes_prompt_if_fail(repo_root: Path) -> None:
250250
"""Attempt to push changes, including tags, for the repository at the given filesystem path.
251251
252-
In case of failure, ask the user
253-
if they would like to try again. Loop until pushing changes succeeds or the
254-
user answers opts to not try again.
252+
In case of failure, ask the user if they would like to try again.
253+
Loop until pushing changes succeeds or the user answers opts to not try again.
255254
"""
256255
while True:
257-
cmd = f"(cd {repo_root} && git push --tags)"
258-
result = os.system(cmd)
259-
cmd = f"(cd {repo_root} && git push origin master)"
260-
result = os.system(cmd)
261-
if result == 0:
256+
cmd = f"git -C {repo_root} push --tags"
257+
subprocess.run([cmd], shell=False, check=False)
258+
cmd = f"git -C {repo_root} push origin master"
259+
result = subprocess.run([cmd], shell=False, check=False)
260+
# Only check the second command, on the theory that both will succeed or both will fail.
261+
if result.returncode == 0:
262262
break
263263
print(
264264
f"Could not push from: {repo_root}; result={result} for command: `{cmd}`"

0 commit comments

Comments
 (0)