fix(git_compat): stop rewriting repo remotes on disk under pygit2 backend

Removing _normalize_remote_urls(): persistently rewriting a repo's SSH origin
to HTTPS mutates on-disk repo state, which is risky if interrupted. The pygit2
backend already neutralizes auth-forcing global config (insteadOf, credential
helpers) by blanking libgit2's config search path, so anonymous HTTPS fetch
works without touching the stored remote.

Manager already prefers the GitPython/system-git backend when a system git is
present (which honors the user's full git config including insteadOf https->ssh
and proxies), and only uses the bundled pygit2 when system git is absent or
CM_USE_PYGIT2=1 is set.

Amp-Thread-ID: https://ampcode.com/threads/T-019eafa0-16a1-726e-91a4-dac1a40d4481
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Jedrzej Kosinski 2026-06-09 21:45:15 -07:00
parent 222ae16b96
commit 4825d1d369

View File

@ -446,18 +446,6 @@ class _Pygit2Repo(GitRepo):
pass
self._repo = _pygit2.Repository(git_dir)
self._working_dir = repo_path
self._normalize_remote_urls()
def _normalize_remote_urls(self):
"""Rewrite any SSH-form remote URLs to anonymous HTTPS so fetch/pull
never require SSH credentials under the pygit2 backend."""
for remote in self._repo.remotes:
https_url = _to_https_url(remote.url)
if https_url != remote.url:
try:
self._repo.remotes.set_url(remote.name, https_url)
except Exception:
pass
@property
def working_dir(self):