Fixed bug, where exception is raised where there shouldn't be raised one

This commit is contained in:
Qubasa
2024-01-10 18:46:54 +01:00
parent b36d0be524
commit 64846eb395
2 changed files with 5 additions and 4 deletions

View File

@@ -54,6 +54,7 @@ def run(
env: dict[str, str] | None = None,
cwd: Path = Path.cwd(),
log: Log = Log.STDERR,
check: bool = True,
) -> CmdOut:
# Start the subprocess
process = subprocess.Popen(
@@ -70,14 +71,14 @@ def run(
# Wait for the subprocess to finish
rc = process.wait()
cmd_out = CmdOut(
stdout_buf,
stderr_buf,
stdout=stdout_buf,
stderr=stderr_buf,
cwd=cwd,
command=shlex.join(cmd),
returncode=process.returncode,
)
if rc != 0:
if check and rc != 0:
raise ClanCmdError(cmd_out)
return cmd_out

View File

@@ -54,7 +54,7 @@ def _commit_file_to_git(repo_dir: Path, file_path: Path, commit_message: str) ->
["nixpkgs#git"],
["git", "-C", str(repo_dir), "diff", "--cached", "--exit-code", str(file_path)],
)
result = run(cmd, cwd=repo_dir)
result = run(cmd, check=False, cwd=repo_dir)
# if there is no diff, return
if result.returncode == 0:
return