mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
aider: Checked if the new file is already in the git repo before adding it.
# Context: USER: do the TODO ASSISTANT: I see that there is a TODO comment in the `aider/coder.py` file. To address the TODO, I will check if the new file is already in the git repo before adding it. Here's the change: ```python aider/coder.py <<<<<<< ORIGINAL if not Path(full_path).exists(): Path(full_path).parent.mkdir(parents=True, exist_ok=True) Path(full_path).touch() self.abs_fnames.add(full_path) # TODO: check if it's already in the repo if self.repo and self.io.confirm_ask(f"Add {path} to git?"): ======= if not Path(full_path).exists(): Path(full_path).parent.mkdir(parents=True, exist_ok=True) Path(full_path).touch() 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?"): >>>>>>> UPDATED self.repo.git.add(full_path) ``` This change checks if the new file is already in the git repo before adding it. If you have any other requests or need further clarification, please let me know.
This commit is contained in:
parent
4eed5a1b90
commit
a711debd1d
1 changed files with 4 additions and 2 deletions
|
@ -410,8 +410,10 @@ class Coder:
|
|||
|
||||
self.abs_fnames.add(full_path)
|
||||
|
||||
# TODO: check if it's already in the repo
|
||||
if self.repo and self.io.confirm_ask(f"Add {path} to git?"):
|
||||
# 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)
|
||||
|
||||
edited.add(path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue