mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 01:35:00 +00:00
check_version shows output for --just-check-update
This commit is contained in:
parent
dadfb464c4
commit
cd86354f12
1 changed files with 14 additions and 3 deletions
|
@ -6,13 +6,16 @@ import packaging.version
|
|||
|
||||
import aider
|
||||
from aider import utils
|
||||
from aider.dump import dump # noqa: F401
|
||||
|
||||
|
||||
def check_version(io, just_check=False):
|
||||
fname = Path.home() / ".aider" / "caches" / "versioncheck"
|
||||
day = 60 * 60 * 24
|
||||
if fname.exists() and time.time() - fname.stat().st_mtime < day:
|
||||
return
|
||||
if not just_check and fname.exists():
|
||||
day = 60 * 60 * 24
|
||||
since = time.time() - fname.stat().st_mtime
|
||||
if since < day:
|
||||
return
|
||||
|
||||
# To keep startup fast, avoid importing this unless needed
|
||||
import requests
|
||||
|
@ -23,6 +26,10 @@ def check_version(io, just_check=False):
|
|||
latest_version = data["info"]["version"]
|
||||
current_version = aider.__version__
|
||||
|
||||
if just_check:
|
||||
io.tool_output(f"Current version: {current_version}")
|
||||
io.tool_output(f"Latest version: {latest_version}")
|
||||
|
||||
is_update_available = packaging.version.parse(latest_version) > packaging.version.parse(
|
||||
current_version
|
||||
)
|
||||
|
@ -34,6 +41,10 @@ def check_version(io, just_check=False):
|
|||
fname.touch()
|
||||
|
||||
if just_check:
|
||||
if is_update_available:
|
||||
io.tool_output("Update available")
|
||||
else:
|
||||
io.tool_output("No update available")
|
||||
return is_update_available
|
||||
|
||||
if not is_update_available:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue