mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-05 12:14:59 +00:00
Merge branch 'main' into litellm-prefill
This commit is contained in:
commit
62fc417655
3 changed files with 19 additions and 5 deletions
|
@ -416,11 +416,11 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
return main(argv, input, output, right_repo_root, return_coder=return_coder)
|
return main(argv, input, output, right_repo_root, return_coder=return_coder)
|
||||||
|
|
||||||
if args.just_check_update:
|
if args.just_check_update:
|
||||||
update_available = check_version(io, just_check=True)
|
update_available = check_version(io, just_check=True, verbose=args.verbose)
|
||||||
return 0 if not update_available else 1
|
return 0 if not update_available else 1
|
||||||
|
|
||||||
if args.check_update:
|
if args.check_update:
|
||||||
check_version(io)
|
check_version(io, verbose=args.verbose)
|
||||||
|
|
||||||
if args.models:
|
if args.models:
|
||||||
models.print_matching_models(io, args.models)
|
models.print_matching_models(io, args.models)
|
||||||
|
|
|
@ -10,12 +10,15 @@ from aider import utils
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
def check_version(io, just_check=False):
|
def check_version(io, just_check=False, verbose=False):
|
||||||
fname = Path.home() / ".aider" / "caches" / "versioncheck"
|
fname = Path.home() / ".aider" / "caches" / "versioncheck"
|
||||||
if not just_check and fname.exists():
|
if not just_check and fname.exists():
|
||||||
day = 60 * 60 * 24
|
day = 60 * 60 * 24
|
||||||
since = time.time() - fname.stat().st_mtime
|
since = time.time() - fname.stat().st_mtime
|
||||||
if since < day:
|
if since < day:
|
||||||
|
if verbose:
|
||||||
|
hours = since / 60 / 60
|
||||||
|
io.tool_output(f"Too soon to check version: {hours:.1f} hours")
|
||||||
return
|
return
|
||||||
|
|
||||||
# To keep startup fast, avoid importing this unless needed
|
# To keep startup fast, avoid importing this unless needed
|
||||||
|
@ -27,7 +30,7 @@ def check_version(io, just_check=False):
|
||||||
latest_version = data["info"]["version"]
|
latest_version = data["info"]["version"]
|
||||||
current_version = aider.__version__
|
current_version = aider.__version__
|
||||||
|
|
||||||
if just_check:
|
if just_check or verbose:
|
||||||
io.tool_output(f"Current version: {current_version}")
|
io.tool_output(f"Current version: {current_version}")
|
||||||
io.tool_output(f"Latest version: {latest_version}")
|
io.tool_output(f"Latest version: {latest_version}")
|
||||||
|
|
||||||
|
@ -41,11 +44,13 @@ def check_version(io, just_check=False):
|
||||||
fname.parent.mkdir(parents=True, exist_ok=True)
|
fname.parent.mkdir(parents=True, exist_ok=True)
|
||||||
fname.touch()
|
fname.touch()
|
||||||
|
|
||||||
if just_check:
|
if just_check or verbose:
|
||||||
if is_update_available:
|
if is_update_available:
|
||||||
io.tool_output("Update available")
|
io.tool_output("Update available")
|
||||||
else:
|
else:
|
||||||
io.tool_output("No update available")
|
io.tool_output("No update available")
|
||||||
|
|
||||||
|
if just_check:
|
||||||
return is_update_available
|
return is_update_available
|
||||||
|
|
||||||
if not is_update_available:
|
if not is_update_available:
|
||||||
|
|
|
@ -224,6 +224,15 @@ class TestMain(TestCase):
|
||||||
|
|
||||||
main(["--yes", fname, "--encoding", "iso-8859-15"])
|
main(["--yes", fname, "--encoding", "iso-8859-15"])
|
||||||
|
|
||||||
|
def test_main_exit_calls_version_check(self):
|
||||||
|
with GitTemporaryDirectory():
|
||||||
|
with patch("aider.main.check_version") as mock_check_version, patch(
|
||||||
|
"aider.main.InputOutput"
|
||||||
|
) as mock_input_output:
|
||||||
|
main(["--exit"], input=DummyInput(), output=DummyOutput())
|
||||||
|
mock_check_version.assert_called_once()
|
||||||
|
mock_input_output.assert_called_once()
|
||||||
|
|
||||||
@patch("aider.main.InputOutput")
|
@patch("aider.main.InputOutput")
|
||||||
@patch("aider.coders.base_coder.Coder.run")
|
@patch("aider.coders.base_coder.Coder.run")
|
||||||
def test_main_message_adds_to_input_history(self, mock_run, MockInputOutput):
|
def test_main_message_adds_to_input_history(self, mock_run, MockInputOutput):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue