From 9567be8c6a43f2492ab5d4f568758a83bffd5625 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 12 May 2023 23:01:45 -0700 Subject: [PATCH] Refactor git file tracking in Coder class. --- aider/coder.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index ec22e49df..4610c5edd 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -411,10 +411,11 @@ class Coder: self.abs_fnames.add(full_path) # Check if the file is already in the repo - tracked_files = set(self.repo.git.ls_files().splitlines()) - relative_fname = self.get_rel_fname(full_path) - if relative_fname not in tracked_files and self.repo and self.io.confirm_ask(f"Add {path} to git?"): - self.repo.git.add(full_path) + if self.repo: + tracked_files = set(self.repo.git.ls_files().splitlines()) + relative_fname = self.get_rel_fname(full_path) + if relative_fname not in tracked_files and self.io.confirm_ask(f"Add {path} to git?"): + self.repo.git.add(full_path) edited.add(path) if utils.do_replace(full_path, original, updated):