Merge branch 'no-git'

This commit is contained in:
Paul Gauthier 2024-12-14 09:49:41 -08:00
commit 60aca3a241
4 changed files with 36 additions and 11 deletions

View file

@ -3,7 +3,11 @@
import sys
from pathlib import Path
import git
try:
import git
except ImportError:
git = None
from diff_match_patch import diff_match_patch
from tqdm import tqdm

View file

@ -9,7 +9,11 @@ import webbrowser
from dataclasses import fields
from pathlib import Path
import git
try:
import git
except ImportError:
git = None
import importlib_resources
from dotenv import load_dotenv
from prompt_toolkit.enums import EditingMode
@ -93,6 +97,9 @@ def make_new_repo(git_root, io):
def setup_git(git_root, io):
if git is None:
return
try:
cwd = Path.cwd()
except OSError:
@ -410,7 +417,9 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
if argv is None:
argv = sys.argv[1:]
if force_git_root:
if git is None:
git_root = None
elif force_git_root:
git_root = force_git_root
else:
git_root = get_git_root()
@ -457,6 +466,9 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
# Parse again to include any arguments that might have been defined in .env
args = parser.parse_args(argv)
if git is None:
args.git = False
if args.analytics_disable:
analytics = Analytics(permanently_disable=True)
print("Analytics have been permanently disabled.")
@ -646,7 +658,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
# We can't know the git repo for sure until after parsing the args.
# If we guessed wrong, reparse because that changes things like
# the location of the config.yml and history files.
if args.git and not force_git_root:
if args.git and not force_git_root and git is not None:
right_repo_root = guessed_wrong_repo(io, git_root, fnames, git_dname)
if right_repo_root:
analytics.event("exit", reason="Recursing with correct repo")

View file

@ -2,7 +2,17 @@ import os
import time
from pathlib import Path, PurePosixPath
import git
try:
import git
ANY_GIT_ERROR = [
git.exc.ODBError,
git.exc.GitError,
]
except ImportError:
git = None
ANY_GIT_ERROR = []
import pathspec
from aider import prompts, utils
@ -10,15 +20,14 @@ from aider.sendchat import simple_send_with_retries
from .dump import dump # noqa: F401
ANY_GIT_ERROR = (
git.exc.ODBError,
git.exc.GitError,
ANY_GIT_ERROR += [
OSError,
IndexError,
BufferError,
TypeError,
ValueError,
)
]
ANY_GIT_ERROR = tuple(ANY_GIT_ERROR)
class GitRepo:

View file

@ -8,8 +8,6 @@ import tempfile
import time
from pathlib import Path
import git
from aider.dump import dump # noqa: F401
IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".webp", ".pdf"}
@ -73,6 +71,8 @@ class GitTemporaryDirectory(ChdirTemporaryDirectory):
def make_repo(path=None):
import git
if not path:
path = "."
repo = git.Repo.init(path)