From 64846eb3953c7cf4657c4607d19ea41ace64ae6a Mon Sep 17 00:00:00 2001 From: Qubasa Date: Wed, 10 Jan 2024 18:46:54 +0100 Subject: [PATCH] Fixed bug, where exception is raised where there shouldn't be raised one --- pkgs/clan-cli/clan_cli/cmd.py | 7 ++++--- pkgs/clan-cli/clan_cli/git.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/cmd.py b/pkgs/clan-cli/clan_cli/cmd.py index 5aeaab904..5c7f8a4dc 100644 --- a/pkgs/clan-cli/clan_cli/cmd.py +++ b/pkgs/clan-cli/clan_cli/cmd.py @@ -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 diff --git a/pkgs/clan-cli/clan_cli/git.py b/pkgs/clan-cli/clan_cli/git.py index be318c32a..977581015 100644 --- a/pkgs/clan-cli/clan_cli/git.py +++ b/pkgs/clan-cli/clan_cli/git.py @@ -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