mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-21 04:44:59 +00:00
provide default git name/email; fix tests
This commit is contained in:
parent
451929f2ca
commit
031c2bc34b
2 changed files with 25 additions and 6 deletions
|
@ -265,9 +265,13 @@ def main(args=None, input=None, output=None):
|
|||
repo = git.Repo.init(os.getcwd())
|
||||
with repo.config_writer() as git_config:
|
||||
if not git_config.has_option("user", "name"):
|
||||
git_config.set_value("user", "name", "Example Name")
|
||||
git_config.set_value("user", "name", "Your Name")
|
||||
io.tool_error('Update git name with: git config --global user.name "Your Name"')
|
||||
if not git_config.has_option("user", "email"):
|
||||
git_config.set_value("user", "email", "example.email@example.com")
|
||||
git_config.set_value("user", "email", "you@example.com")
|
||||
io.tool_error(
|
||||
'Update git email with: git config --global user.email "you@example.com"'
|
||||
)
|
||||
io.tool_output("Git repository created in the current working directory.")
|
||||
|
||||
if args.verbose:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
@ -38,7 +37,15 @@ class TestCoder(unittest.TestCase):
|
|||
coder.check_for_file_mentions("Please check file1.txt and file2.py")
|
||||
|
||||
# Check if coder.abs_fnames contains both files
|
||||
expected_files = {os.path.abspath("file1.txt"), os.path.abspath("file2.py")}
|
||||
expected_files = set(
|
||||
map(
|
||||
str,
|
||||
[
|
||||
Path(coder.root) / "file1.txt",
|
||||
Path(coder.root) / "file2.py",
|
||||
],
|
||||
)
|
||||
)
|
||||
self.assertEqual(coder.abs_fnames, expected_files)
|
||||
|
||||
def test_check_for_filename_mentions_of_longer_paths(self):
|
||||
|
@ -50,14 +57,22 @@ class TestCoder(unittest.TestCase):
|
|||
|
||||
# Mock the git repo
|
||||
mock_repo = MagicMock()
|
||||
mock_repo.git.ls_files.return_value = "./file1.txt\n./file2.py"
|
||||
mock_repo.git.ls_files.return_value = "file1.txt\nfile2.py"
|
||||
coder.repo = mock_repo
|
||||
|
||||
# Call the check_for_file_mentions method
|
||||
coder.check_for_file_mentions("Please check file1.txt and file2.py")
|
||||
|
||||
# Check if coder.abs_fnames contains both files
|
||||
expected_files = {os.path.abspath("file1.txt"), os.path.abspath("file2.py")}
|
||||
expected_files = set(
|
||||
map(
|
||||
str,
|
||||
[
|
||||
Path(coder.root) / "file1.txt",
|
||||
Path(coder.root) / "file2.py",
|
||||
],
|
||||
)
|
||||
)
|
||||
self.assertEqual(coder.abs_fnames, expected_files)
|
||||
|
||||
def test_check_for_ambiguous_filename_mentions_of_longer_paths(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue