diff --git a/svn_mirror/mirror.py b/svn_mirror/mirror.py index c54691e..dbdf024 100644 --- a/svn_mirror/mirror.py +++ b/svn_mirror/mirror.py @@ -119,6 +119,7 @@ class Mirror: shutil.rmtree(import_dir) try: + self._cache_svn_credentials() self._run_git_svn_clone(import_dir) self._push_import_to_bare(import_dir) mappings = self._read_rev_maps(import_dir) @@ -178,6 +179,27 @@ class Mirror: except subprocess.TimeoutExpired: raise MirrorError("git svn --version timed out") + def _cache_svn_credentials(self): + """Pre-populate SVN auth cache so git svn doesn't prompt.""" + svn_cfg = self.config.svn + if not svn_cfg.username: + return + import subprocess + try: + r = subprocess.run( + ["svn", "info", "--non-interactive", + svn_cfg.url.rstrip("/") + "/" + svn_cfg.trunk] + + svn_cfg.auth_args(), + capture_output=True, timeout=30, + ) + if r.returncode != 0: + err = (r.stderr or b"").decode("utf-8", errors="replace").strip() + logger.warning("SVN credential cache failed (non-fatal): %s", err) + else: + logger.debug("SVN credentials cached") + except Exception as e: + logger.warning("SVN credential cache skipped: %s", e) + def _run_git_svn_clone(self, target: Path): """Execute git svn clone --no-metadata for the initial import.""" svn_cfg = self.config.svn @@ -203,6 +225,7 @@ class Mirror: process = subprocess.Popen( args, + stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,