Repository navigation
Expose the Aegisub version to Lua as aegisub.version - #732
CoffeeFlux wants to merge 1 commit into
Conversation
Scripts have so far only been able to check lua_automation_version, which hasn't changed in years, so there's no way for them to check whether newer API additions are available. aegisub.version is a table with: - string: the version string, e.g. "3.5.0" for a release or "9900-master-4e440a614" for a development build - release: whether this was built from a release tag - build: the build number, which increases with each commit on master (0 when built from a shallow clone) - major, minor, patch: the version numbers, for X.Y.Z release tags only Prereleases such as 3.5.0-beta deliberately get no version numbers, so that checks for a minimum version don't pass for its prereleases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I need to fix up the actual values returned here, but we definitely need a richer way to fetch the version than just the automation API counter, unless we want to start bumping that any time we change anything. The motivation here in particular is wanting to add an API for DepCtrl to use, but needing a way to gate on it. I'm inclined to start by exposing less and seeing what's useful, so maybe the build number is the right place to start, along with the semver version set in meson? |
|
While this does seem logical, is there a reason against scripts just checking for the specific features they expect to be present? e.g. EDIT: i somehow entirely glossed over this being mentioned in OP already, sorry. still, though: it's not clear to me what those cases are where you couldn't check for function existence (unless you're planning on significant backwards-compat breaks, i guess?) |
|
I guess one case I can think of is where an API function that used to take three arguments is extended to take an optional fourth argument in a newer version, or if Either way, exposing the version explicitly is just more idiomatic. As for the specific API, the conclusion is that it looks good to me, but for future reference here's why I discarded some alternatives:
Regarding the code:
|
Scripts can currently only check
aegisub.lua_automation_version, which has been 4 for years, so there's no way for them to tell whether newer API additions exist. DependencyControl in particular needs to guard on the upcoming CLI mode API (#670).This adds
aegisub.version, a table with:string"3.5.0"for a release or"9900-master-4e440a614"for a development buildreleasebuild0when built from a shallow clone)major,minor,patchX.Y.Zrelease tags onlyDevelopment builds have no semantic version, so they only get
stringandbuild. Prereleases such as3.5.0-betadeliberately get no version numbers either, so that a check likemajor > 3 or (major == 3 and minor >= 5)doesn't pass for prereleases of that version.For new APIs, checking for the function itself (
if aegisub.foo then) is still the most robust guard; this is for cases where that isn't possible.Tested on macOS with an autoload script that dumps the table:
string=9902-…-edabbb808 release=false build=9902, no numbersv3.6.0tagstring=3.6.0 release=true build=9902 major=3 minor=6 patch=0v3.6.0-betatagstring=3.6.0-beta release=true build=9902, no numbersThe automation API docs will need a matching entry.
🤖 Generated with Claude Code