Skip to content

Commit 031c2bc

Browse files
committed
provide default git name/email; fix tests
1 parent 451929f commit 031c2bc

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

aider/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,13 @@ def main(args=None, input=None, output=None):
265265
repo = git.Repo.init(os.getcwd())
266266
with repo.config_writer() as git_config:
267267
if not git_config.has_option("user", "name"):
268-
git_config.set_value("user", "name", "Example Name")
268+
git_config.set_value("user", "name", "Your Name")
269+
io.tool_error('Update git name with: git config --global user.name "Your Name"')
269270
if not git_config.has_option("user", "email"):
270-
git_config.set_value("user", "email", "[email protected]")
271+
git_config.set_value("user", "email", "[email protected]")
272+
io.tool_error(
273+
'Update git email with: git config --global user.email "[email protected]"'
274+
)
271275
io.tool_output("Git repository created in the current working directory.")
272276

273277
if args.verbose:

tests/test_coder.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import tempfile
32
import unittest
43
from pathlib import Path
@@ -38,7 +37,15 @@ def test_check_for_file_mentions(self):
3837
coder.check_for_file_mentions("Please check file1.txt and file2.py")
3938

4039
# Check if coder.abs_fnames contains both files
41-
expected_files = {os.path.abspath("file1.txt"), os.path.abspath("file2.py")}
40+
expected_files = set(
41+
map(
42+
str,
43+
[
44+
Path(coder.root) / "file1.txt",
45+
Path(coder.root) / "file2.py",
46+
],
47+
)
48+
)
4249
self.assertEqual(coder.abs_fnames, expected_files)
4350

4451
def test_check_for_filename_mentions_of_longer_paths(self):
@@ -50,14 +57,22 @@ def test_check_for_filename_mentions_of_longer_paths(self):
5057

5158
# Mock the git repo
5259
mock_repo = MagicMock()
53-
mock_repo.git.ls_files.return_value = "./file1.txt\n./file2.py"
60+
mock_repo.git.ls_files.return_value = "file1.txt\nfile2.py"
5461
coder.repo = mock_repo
5562

5663
# Call the check_for_file_mentions method
5764
coder.check_for_file_mentions("Please check file1.txt and file2.py")
5865

5966
# Check if coder.abs_fnames contains both files
60-
expected_files = {os.path.abspath("file1.txt"), os.path.abspath("file2.py")}
67+
expected_files = set(
68+
map(
69+
str,
70+
[
71+
Path(coder.root) / "file1.txt",
72+
Path(coder.root) / "file2.py",
73+
],
74+
)
75+
)
6176
self.assertEqual(coder.abs_fnames, expected_files)
6277

6378
def test_check_for_ambiguous_filename_mentions_of_longer_paths(self):

0 commit comments

Comments
 (0)