diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index dc93b547d..8175965ad 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -434,13 +434,7 @@ class Coder: bold = False def find_common_root(self): - if len(self.abs_fnames) == 1: - self.root = os.path.dirname(list(self.abs_fnames)[0]) - elif self.abs_fnames: - self.root = os.path.commonpath(list(self.abs_fnames)) - else: - self.root = os.getcwd() - + self.root = utils.find_common_root(self.abs_fnames) self.root = utils.safe_abs_path(self.root) def add_rel_fname(self, rel_fname): diff --git a/aider/utils.py b/aider/utils.py index d0a8e5130..ca4d6213d 100644 --- a/aider/utils.py +++ b/aider/utils.py @@ -272,6 +272,16 @@ class Spinner: print("\r" + " " * (len(self.text) + 3)) +import os + +def find_common_root(abs_fnames): + if len(abs_fnames) == 1: + return os.path.dirname(list(abs_fnames)[0]) + elif abs_fnames: + return os.path.commonpath(list(abs_fnames)) + else: + return os.getcwd() + def check_pip_install_extra(io, module, prompt, pip_install_cmd): try: __import__(module)