From cf1b7e9994201cc5c1e4912d0c87454689bdfd6e Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Wed, 24 Jun 2026 11:49:40 +0200 Subject: [PATCH] fix: add --non-interactive to git_to_svn._run_svn, fix stdin/input exclusivity --- svn_mirror/git_to_svn.py | 20 ++++++++++++-------- svn_mirror/svn.py | 18 ++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/svn_mirror/git_to_svn.py b/svn_mirror/git_to_svn.py index b4067e7..a78659c 100644 --- a/svn_mirror/git_to_svn.py +++ b/svn_mirror/git_to_svn.py @@ -96,16 +96,20 @@ def _run_svn(args: list, input: bytes = None, timeout: int = 120, """Run an svn command. If *wc* is given, run from that directory.""" if auth_args: args = auth_args + args + args = ["--non-interactive"] + args env = {**os.environ, "LC_ALL": "C.UTF-8"} + kwargs = dict( + capture_output=True, + timeout=timeout, + cwd=str(wc) if wc else None, + env=env, + ) + if input is not None: + kwargs["input"] = input + else: + kwargs["stdin"] = subprocess.DEVNULL try: - r = subprocess.run( - ["svn"] + args, - input=input, - capture_output=True, - timeout=timeout, - cwd=str(wc) if wc else None, - env=env, - ) + r = subprocess.run(["svn"] + args, **kwargs) except FileNotFoundError: raise GitToSVNError("svn CLI not found – is subversion installed?") except subprocess.TimeoutExpired: diff --git a/svn_mirror/svn.py b/svn_mirror/svn.py index 9a14c61..df849e9 100644 --- a/svn_mirror/svn.py +++ b/svn_mirror/svn.py @@ -35,15 +35,17 @@ def _run_svn(args: list, input: bytes = None, timeout: int = 120, args = auth_args + args args = ["--non-interactive"] + args env = {**os.environ, "LC_ALL": "C.UTF-8"} + kwargs = dict( + capture_output=True, + timeout=timeout, + env=env, + ) + if input is not None: + kwargs["input"] = input + else: + kwargs["stdin"] = subprocess.DEVNULL try: - r = subprocess.run( - ["svn"] + args, - stdin=subprocess.DEVNULL, - input=input, - capture_output=True, - timeout=timeout, - env=env, - ) + r = subprocess.run(["svn"] + args, **kwargs) except FileNotFoundError: raise SVNError("svn CLI not found – is subversion installed?") except subprocess.TimeoutExpired: