mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
refac
This commit is contained in:
parent
0f5264b196
commit
08764215c3
2 changed files with 34 additions and 31 deletions
|
@ -717,6 +717,35 @@ class Coder:
|
|||
def get_addable_relative_files(self):
|
||||
return set(self.get_all_relative_files()) - set(self.get_inchat_relative_files())
|
||||
|
||||
def allowed_to_edit(self, path):
|
||||
full_path = os.path.abspath(os.path.join(self.root, path))
|
||||
|
||||
if full_path in self.abs_fnames:
|
||||
return full_path
|
||||
|
||||
if not Path(full_path).exists():
|
||||
question = f"Allow creation of new file {path}?" # noqa: E501
|
||||
else:
|
||||
question = f"Allow edits to {path} which was not previously provided?" # noqa: E501
|
||||
if not self.io.confirm_ask(question):
|
||||
self.io.tool_error(f"Skipping edit to {path}")
|
||||
return
|
||||
|
||||
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
|
||||
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)
|
||||
|
||||
return full_path
|
||||
|
||||
def apply_updates(self):
|
||||
try:
|
||||
edited = self.update_files()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue