Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change

## [Unreleased]

### Changed

- When an update is available, report this on every run of pretext.

## [2.29.2] - 2025-09-10

Includes updates to core through commit: [016b805](https://github.com/PreTeXtBook/pretext/commit/016b805e8716fc8d4246027f3e999c566a57442c)
Expand Down
13 changes: 10 additions & 3 deletions pretext/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,14 +959,20 @@ def check_for_updates() -> None:
"""
# check whether we have looked for updates today
last_check = resources.resource_base_path() / "last_update_check.txt"
current_version = VERSION
if last_check.exists():
with open(last_check, "r") as f:
last_date = f.read()
last_date = f.readline().strip()
cached_version = f.readline().strip()
if last_date == str(datetime.date.today()):
log.debug("Already checked for updates today.")
if is_earlier_version(current_version, cached_version):
log.info(
f"Version {cached_version.strip()} of pretext is available. You are currently using version {current_version}."
)
log.info("To upgrade, run `pretext upgrade`.")
return
# Check for updates
current_version = VERSION
latest = latest_version()
if latest is None:
log.debug("Could not check for updates.")
Expand All @@ -984,7 +990,8 @@ def check_for_updates() -> None:
log.info(f"You are using the latest version of pretext, {current_version}.\n")
# update the last check date
with open(last_check, "w") as f:
f.write(str(datetime.date.today()))
f.write(str(datetime.date.today()) + "\n")
f.write(latest + "\n")


def report_version() -> None:
Expand Down