fix bug blocking addition of subdir filename mentions

This commit is contained in:
Paul Gauthier 2023-07-14 20:00:04 -07:00
parent 16a21d9844
commit 78d9d014f2
2 changed files with 5 additions and 2 deletions

View file

@ -586,6 +586,9 @@ class Coder:
mentioned_rel_fnames = set() mentioned_rel_fnames = set()
fname_to_rel_fnames = {} fname_to_rel_fnames = {}
for rel_fname in addable_rel_fnames: for rel_fname in addable_rel_fnames:
if rel_fname in words:
mentioned_rel_fnames.add(str(rel_fname))
fname = os.path.basename(rel_fname) fname = os.path.basename(rel_fname)
if fname not in fname_to_rel_fnames: if fname not in fname_to_rel_fnames:
fname_to_rel_fnames[fname] = [] fname_to_rel_fnames[fname] = []

View file

@ -108,7 +108,7 @@ class TestCoder(unittest.TestCase):
# Call the check_for_file_mentions method # Call the check_for_file_mentions method
coder.check_for_file_mentions("Please check file1.txt!") coder.check_for_file_mentions("Please check file1.txt!")
self.assertEqual(coder.abs_fnames, set()) self.assertEqual(coder.abs_fnames, set([str(Path("file1.txt").resolve())]))
def test_check_for_subdir_mention(self): def test_check_for_subdir_mention(self):
# Mock the IO object # Mock the IO object
@ -124,7 +124,7 @@ class TestCoder(unittest.TestCase):
# Call the check_for_file_mentions method # Call the check_for_file_mentions method
coder.check_for_file_mentions("Please check `other/file1.txt`") coder.check_for_file_mentions("Please check `other/file1.txt`")
self.assertEqual(coder.abs_fnames, set([Path("other/file1.txt").resolve()])) self.assertEqual(coder.abs_fnames, set([str(Path("other/file1.txt").resolve())]))
def test_get_commit_message(self): def test_get_commit_message(self):
# Mock the IO object # Mock the IO object