feat: implement just_version() function#2892
Conversation
42cc35d to
01c3e34
Compare
01c3e34 to
21cde44
Compare
|
@casey hi, are there any blockers or concerns with this? Thx! |
|
Sorry if I'm missing something, but so far the proposed use cases for this function revolve around detecting whether the running Are there any other use cases for |
|
ironically, my biggest use case is NOT to do version check, but rather to reliably report the version from inside. All my # Print environment info
env-info:
@echo "Running for '{{main_crate}}' crate {{if ci_mode == '1' {'in CI mode'} else {'in dev mode'} }} on {{os()}} / {{arch()}}"
{{just_executable()}} --version
rustc --version
cargo --version
rustup --versionWhat I recently discovered is that this breaks on Windows - because Do note that with every function we will have the "before" and "after" -- so anyone who wants to use any new function will have to ensure that the version of the just executable will handle it. Not much we can do about it "in retrospect" other than to create some external wrappers. |
| set dotenv-load | ||
| set export | ||
|
|
||
| _required_just_ver := if semver_matches(just_version(), '>=1.43.0') == 'true' { |
There was a problem hiding this comment.
We should remove this, since this is a fragile way to enforce a particular just version, since the justfile may fail to compile at all with the older version.
| } | ||
|
|
||
| fn just_version(_context: Context) -> FunctionResult { | ||
| Ok(env!("CARGO_PKG_VERSION").to_string()) |
There was a problem hiding this comment.
| Ok(env!("CARGO_PKG_VERSION").to_string()) | |
| Ok(env!("CARGO_PKG_VERSION").into()) |
| r" | ||
| foo: | ||
| echo {{arch()}} {{os()}} {{os_family()}} {{num_cpus()}} | ||
| echo {{arch()}} {{os()}} {{os_family()}} {{num_cpus()}} {{just_version()}} |
There was a problem hiding this comment.
Let's add a single extra test for this, instead of making these tests more complicated.
| `"macos"`, `"netbsd"`, `"openbsd"`, `"solaris"`, and `"windows"`. | ||
| - `os_family()` — Operating system family; possible values are: `"unix"` and | ||
| `"windows"`. | ||
| - `just_version()`<sup>master</sup> — The version of `just` being run, e.g. `"1.42.5"`. |
There was a problem hiding this comment.
I would leave off the e.g.
| - `just_version()`<sup>master</sup> — The version of `just` being run, e.g. `"1.42.5"`. | |
| - `just_version()`<sup>master</sup> — The version of `just` being run. |
implement #2616
Note that this also allows #2290