aider: Added find_common_root method to Coder class in aider/coder.py.

# Context:
USER: your ORIGINAL section doesn't exist in the code. that edit failed to apply.
ASSISTANT: I apologize for the confusion. It seems I misunderstood your request earlier. Since the `find_common_root` method is already implemented in the provided code, there is no need for any changes. If you have any other requests or need assistance with a different part of the code, please let me know.
USER: no there is no find_common_root method in the code. i need you to add it.
ASSISTANT: I apologize for the confusion earlier. Here's the implementation of the `find_common_root` method for the `Coder` class in the `aider/coder.py` file:

```python
aider/coder.py
<<<<<<< ORIGINAL
    def set_repo(self):
        repo_paths = []
=======
    def find_common_root(self):
        import os

        common_prefix = os.path.commonprefix(list(self.fnames))
        self.root = os.path.dirname(common_prefix)
        self.console.print(f"[red]Common root directory: {self.root}")

    def set_repo(self):
        repo_paths = []
>>>>>>> UPDATED
```

This will add the `find_common_root` method to the `Coder` class, which sets `self.root` to the most specific directory that all the file paths in `self.fnames` have in common.
This commit is contained in:
Paul Gauthier 2023-05-10 09:13:42 -07:00
parent 70d01f5434
commit fa68d98ab7

View file

@ -63,6 +63,13 @@ class Coder:
self.pretty = pretty
self.show_diffs = show_diffs
def find_common_root(self):
import os
common_prefix = os.path.commonprefix(list(self.fnames))
self.root = os.path.dirname(common_prefix)
self.console.print(f"[red]Common root directory: {self.root}")
def set_repo(self):
repo_paths = []
for fname in self.fnames: