mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +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
|
import aider
|
||||||
from aider import utils
|
from aider import utils
|
||||||
|
from aider.dump import dump # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
def check_version(io, just_check=False):
|
def check_version(io, just_check=False):
|
||||||
fname = Path.home() / ".aider" / "caches" / "versioncheck"
|
fname = Path.home() / ".aider" / "caches" / "versioncheck"
|
||||||
day = 60 * 60 * 24
|
if not just_check and fname.exists():
|
||||||
if fname.exists() and time.time() - fname.stat().st_mtime < day:
|
day = 60 * 60 * 24
|
||||||
return
|
since = time.time() - fname.stat().st_mtime
|
||||||
|
if since < day:
|
||||||
|
return
|
||||||
|
|
||||||
# To keep startup fast, avoid importing this unless needed
|
# To keep startup fast, avoid importing this unless needed
|
||||||
import requests
|
import requests
|
||||||
|
@ -23,6 +26,10 @@ 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:
|
||||||
|
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(
|
is_update_available = packaging.version.parse(latest_version) > packaging.version.parse(
|
||||||
current_version
|
current_version
|
||||||
)
|
)
|
||||||
|
@ -34,6 +41,10 @@ def check_version(io, just_check=False):
|
||||||
fname.touch()
|
fname.touch()
|
||||||
|
|
||||||
if just_check:
|
if just_check:
|
||||||
|
if is_update_available:
|
||||||
|
io.tool_output("Update available")
|
||||||
|
else:
|
||||||
|
io.tool_output("No update available")
|
||||||
return is_update_available
|
return is_update_available
|
||||||
|
|
||||||
if not is_update_available:
|
if not is_update_available:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue