mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
Return files without any tags at all at the tail of the ranked_tags list
This commit is contained in:
parent
dfcf813ad6
commit
53e8c65745
2 changed files with 23 additions and 1 deletions
|
@ -306,8 +306,19 @@ class RepoMap:
|
|||
continue
|
||||
ranked_tags += list(definitions.get((fname, ident), []))
|
||||
|
||||
rel_other_fnames_without_tags = set(
|
||||
os.path.relpath(fname, self.root) for fname in other_fnames
|
||||
)
|
||||
|
||||
fnames_already_included = set(rt[0] for rt in ranked_tags)
|
||||
|
||||
top_rank = sorted([(rank, node) for (node, rank) in ranked.items()], reverse=True)
|
||||
for rank, fname in top_rank:
|
||||
rel_other_fnames_without_tags.remove(fname)
|
||||
if fname not in fnames_already_included:
|
||||
ranked_tags.append((fname,))
|
||||
|
||||
for fname in rel_other_fnames_without_tags:
|
||||
ranked_tags.append((fname,))
|
||||
|
||||
return ranked_tags
|
||||
|
|
|
@ -53,6 +53,9 @@ print(obj.my_method(1, 2))
|
|||
print(my_function(3, 4))
|
||||
"""
|
||||
|
||||
test_file3 = "test_file_pass.py"
|
||||
file_content3 = "pass"
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
with open(os.path.join(temp_dir, test_file1), "w") as f:
|
||||
f.write(file_content1)
|
||||
|
@ -60,8 +63,15 @@ print(my_function(3, 4))
|
|||
with open(os.path.join(temp_dir, test_file2), "w") as f:
|
||||
f.write(file_content2)
|
||||
|
||||
with open(os.path.join(temp_dir, test_file3), "w") as f:
|
||||
f.write(file_content3)
|
||||
|
||||
repo_map = RepoMap(root=temp_dir)
|
||||
other_files = [os.path.join(temp_dir, test_file1), os.path.join(temp_dir, test_file2)]
|
||||
other_files = [
|
||||
os.path.join(temp_dir, test_file1),
|
||||
os.path.join(temp_dir, test_file2),
|
||||
os.path.join(temp_dir, test_file3),
|
||||
]
|
||||
result = repo_map.get_repo_map([], other_files)
|
||||
|
||||
# Check if the result contains the expected tags map with identifiers
|
||||
|
@ -69,6 +79,7 @@ print(my_function(3, 4))
|
|||
self.assertIn("MyClass", result)
|
||||
self.assertIn("my_method", result)
|
||||
self.assertIn("my_function", result)
|
||||
self.assertIn("test_file_pass.py", result)
|
||||
|
||||
def test_check_for_ctags_failure(self):
|
||||
with patch("subprocess.run") as mock_run:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue