mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-21 21:04:59 +00:00
Merge branch 'main' into refactor-repo
This commit is contained in:
commit
e74bfc21d0
2 changed files with 25 additions and 2 deletions
|
@ -676,10 +676,10 @@ class Coder:
|
|||
return files
|
||||
|
||||
def get_last_modified(self):
|
||||
files = self.get_all_abs_files()
|
||||
files = [Path(fn) for fn in self.get_all_abs_files() if Path(fn).exists()]
|
||||
if not files:
|
||||
return 0
|
||||
return max(Path(path).stat().st_mtime for path in files)
|
||||
return max(path.stat().st_mtime for path in files)
|
||||
|
||||
def get_addable_relative_files(self):
|
||||
return set(self.get_all_relative_files()) - set(self.get_inchat_relative_files())
|
||||
|
|
|
@ -23,6 +23,29 @@ class TestCoder(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
self.patcher.stop()
|
||||
|
||||
def test_get_last_modified(self):
|
||||
# Mock the IO object
|
||||
mock_io = MagicMock()
|
||||
|
||||
with GitTemporaryDirectory():
|
||||
repo = git.Repo(Path.cwd())
|
||||
fname = Path("new.txt")
|
||||
fname.touch()
|
||||
repo.git.add(str(fname))
|
||||
repo.git.commit("-m", "new")
|
||||
|
||||
# Initialize the Coder object with the mocked IO and mocked repo
|
||||
coder = Coder.create(models.GPT4, None, mock_io)
|
||||
|
||||
mod = coder.get_last_modified()
|
||||
|
||||
fname.write_text("hi")
|
||||
mod_newer = coder.get_last_modified()
|
||||
self.assertLess(mod, mod_newer)
|
||||
|
||||
fname.unlink()
|
||||
self.assertEqual(coder.get_last_modified(), 0)
|
||||
|
||||
def test_should_dirty_commit(self):
|
||||
# Mock the IO object
|
||||
mock_io = MagicMock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue