luxe update and /update, editable question answers, and a version bump owed once per release
- luxe update and /update update Luxe with the command for however it was installed (cargo or Homebrew), run one program at a time with the terminal attached, then check that the luxe on PATH is the new version. Luxe never downloads or replaces its own binary. The start screen says "Update available · /update". - A question's typed answer edits at its caret: arrows, word jumps, Home, End and Delete work, and up and down move through a wrapped answer before leaving it. - The version check owes a bump once per release: the version on main is the next release, and only a released one (a v-tag) has to move. - Dependency updates arrive through the sync, so Dependabot and the weekly jobs no longer run here.
This commit is contained in:
@@ -11,6 +11,7 @@ pub(crate) mod headless;
|
||||
mod models_command;
|
||||
mod rpc;
|
||||
mod tui;
|
||||
pub(crate) mod update_command;
|
||||
mod wire_command;
|
||||
mod worktree;
|
||||
|
||||
@@ -40,6 +41,10 @@ pub(crate) async fn run(mut args: Args) -> anyhow::Result<()> {
|
||||
if let Some(SubCommand::Docs(docs)) = &args.command {
|
||||
return docs_command::run(docs);
|
||||
}
|
||||
// An update is about this binary, not a project, so it runs from anywhere
|
||||
if let Some(SubCommand::Update(update)) = &args.command {
|
||||
return update_command::run(update.check).await;
|
||||
}
|
||||
args.validate()?;
|
||||
// Where the project begins, which is not always where the shell was standing. Everything after
|
||||
// this — sessions, logs, instructions, the file index, every tool's relative path — is measured
|
||||
@@ -114,8 +119,8 @@ pub(crate) async fn run(mut args: Args) -> anyhow::Result<()> {
|
||||
}
|
||||
SubCommand::Doctor => return run_doctor_command(settings).await,
|
||||
SubCommand::Wire(wire_args) => return run_wire_command(wire_args),
|
||||
SubCommand::Docs(_) => {
|
||||
unreachable!("`luxe docs` returned before a project was entered")
|
||||
SubCommand::Docs(_) | SubCommand::Update(_) => {
|
||||
unreachable!("`luxe docs` and `luxe update` return before a project is entered")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@ impl Args {
|
||||
| SubCommand::Init(_)
|
||||
| SubCommand::Models(_)
|
||||
| SubCommand::Sessions(_)
|
||||
| SubCommand::Update(_)
|
||||
| SubCommand::Wire(_),
|
||||
) => false,
|
||||
}
|
||||
@@ -255,6 +256,7 @@ impl Args {
|
||||
| SubCommand::Mcp(_)
|
||||
| SubCommand::Models(_)
|
||||
| SubCommand::Sessions(_)
|
||||
| SubCommand::Update(_)
|
||||
| SubCommand::Wire(_),
|
||||
) => false,
|
||||
}
|
||||
|
||||
@@ -21,10 +21,20 @@ pub(crate) enum SubCommand {
|
||||
Models(ModelsArgs),
|
||||
/// List this project's sessions.
|
||||
Sessions(SessionsArgs),
|
||||
/// Update Luxe with the command for however it was installed.
|
||||
Update(UpdateArgs),
|
||||
/// Summarize a `LUXE_WIRE_LOG` capture.
|
||||
Wire(WireArgs),
|
||||
}
|
||||
|
||||
/// Update arguments.
|
||||
#[derive(Parser, Debug)]
|
||||
pub(crate) struct UpdateArgs {
|
||||
/// Only say whether a newer release exists, and how to get it.
|
||||
#[arg(long)]
|
||||
pub(crate) check: bool,
|
||||
}
|
||||
|
||||
/// Docs arguments.
|
||||
#[derive(Parser, Debug)]
|
||||
pub(crate) struct DocsArgs {
|
||||
|
||||
@@ -5,11 +5,15 @@ use super::worktree::{
|
||||
check_out_pull_request, enter_session_worktree, remove_worktree, take_up_issue_in_worktree,
|
||||
};
|
||||
|
||||
/// The one line under the dashboard, or nothing.
|
||||
/// The one line under the dashboard, or nothing: that an update exists, and how to take it. The
|
||||
/// versions and the command wait for `/update`, where the reader decides.
|
||||
fn footer_note(repo_root: &std::path::Path) -> Option<String> {
|
||||
crate::update_check::cached_notice(repo_root).map(|notice| notice.line())
|
||||
crate::update_check::cached_notice(repo_root).map(|_| UPDATE_HINT.to_string())
|
||||
}
|
||||
|
||||
/// What the dashboard says when a newer Luxe exists.
|
||||
const UPDATE_HINT: &str = "Update available · /update";
|
||||
|
||||
/// Whether the startup dashboard should be shown.
|
||||
///
|
||||
/// Suppressed when resuming, when the session already has its work — `--issue` or `--pr` said
|
||||
@@ -151,6 +155,12 @@ impl Next<'_> {
|
||||
remove_worktree(&self.settings.state_root, &path).await;
|
||||
return Ok(Flow::Leave);
|
||||
}
|
||||
TuiExit::Update => {
|
||||
// The terminal is the reader's again, so the package manager's output reaches them
|
||||
shutdown_workspace_services().await;
|
||||
super::update_command::run(false).await?;
|
||||
return Ok(Flow::Leave);
|
||||
}
|
||||
TuiExit::TakeUpIssue(number) => {
|
||||
// A new session on the issue, in its worktree; the one left stays as it was
|
||||
shutdown_workspace_services().await;
|
||||
@@ -342,3 +352,28 @@ pub(super) async fn shutdown_workspace_services() {
|
||||
tracing::warn!("workspace service shutdown timed out; relying on kill-on-drop reaping");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use luxe_core::update::UpdateState;
|
||||
|
||||
/// The start screen says only that an update exists and how to take it, and nothing when it
|
||||
/// does not; the versions and the command wait for `/update`.
|
||||
///
|
||||
/// Mutates the environment, which nextest makes safe by giving each test its own process.
|
||||
#[test]
|
||||
fn the_footer_says_an_update_is_available_and_how() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let cache = dir.path().join("update.json");
|
||||
std::env::set_var("LUXE_UPDATE_PATH", &cache);
|
||||
std::env::set_var("LUXE_UPDATE_CHECK", "1");
|
||||
let now = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap();
|
||||
for (latest, footer) in [("99.0.0", Some("Update available · /update")), ("0.0.1", None)] {
|
||||
let state = UpdateState { latest: Some(latest.into()), checked_at: now.as_secs() };
|
||||
state.store(&cache).expect("store");
|
||||
assert_eq!(super::footer_note(dir.path()).as_deref(), footer, "{latest}");
|
||||
}
|
||||
std::env::remove_var("LUXE_UPDATE_PATH");
|
||||
std::env::remove_var("LUXE_UPDATE_CHECK");
|
||||
}
|
||||
}
|
||||
|
||||
142
crates/luxe-cli/src/cli/update_command.rs
Normal file
142
crates/luxe-cli/src/cli/update_command.rs
Normal file
@@ -0,0 +1,142 @@
|
||||
//! `luxe update` — run the update this install's owner provides, then check that it took.
|
||||
//!
|
||||
//! The policy is [`luxe_core::update`]'s: which owner installed this copy, which commands update
|
||||
//! it, and a refusal where Luxe cannot know them. This runs those commands one program at a time
|
||||
//! with the terminal attached, so the reader sees the package manager's own output, and Luxe never
|
||||
//! writes a binary itself. `/update` on the dashboard comes here too, once the TUI has handed the
|
||||
//! terminal back.
|
||||
|
||||
use anyhow::{anyhow, bail, Context};
|
||||
use luxe_core::update::{self, InstallSource};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Checks for a newer release now and, unless `check_only`, runs the update and checks the result.
|
||||
pub(crate) async fn run(check_only: bool) -> anyhow::Result<()> {
|
||||
let current = luxe_core::version::VERSION;
|
||||
let latest = crate::update_check::check_now()
|
||||
.await
|
||||
.map_err(|error| anyhow!("could not check for a newer release: {error}"))?;
|
||||
if !update::is_newer(&latest, current) {
|
||||
println!("Luxe {current} is the newest release.");
|
||||
return Ok(());
|
||||
}
|
||||
println!("Luxe {latest} is available (you have {current}).");
|
||||
let source = InstallSource::detect();
|
||||
match (source.update_steps(), check_only) {
|
||||
(Some(steps), false) if !cfg!(windows) => {
|
||||
run_steps(steps).await?;
|
||||
report(installed_now(&latest).await)
|
||||
}
|
||||
_ => {
|
||||
println!("{}", instructions(source, check_only, cfg!(windows)));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What to tell a reader Luxe will not run an update for: they asked only to check, Windows cannot
|
||||
/// replace the running program, or no owner's command is known.
|
||||
fn instructions(source: InstallSource, check_only: bool, windows: bool) -> String {
|
||||
match source.update_command() {
|
||||
Some(command) if !check_only && windows => format!(
|
||||
"Windows can't replace Luxe while it runs, so run this once it has exited: {command}"
|
||||
),
|
||||
Some(_) if check_only => format!("Run `luxe update`, or {}.", source.advice()),
|
||||
_ => format!("To update: {}.", source.advice()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs each step in turn, the terminal attached, stopping at the first that fails.
|
||||
async fn run_steps(steps: &[&[&str]]) -> anyhow::Result<()> {
|
||||
for step in steps {
|
||||
let Some((program, args)) = step.split_first() else { continue };
|
||||
let line = step.join(" ");
|
||||
println!("Running: {line}");
|
||||
let status = tokio::process::Command::new(program)
|
||||
.args(args)
|
||||
.status()
|
||||
.await
|
||||
.with_context(|| format!("could not start `{program}`"))?;
|
||||
if !status.success() {
|
||||
bail!("`{line}` failed ({status}), so Luxe is unchanged");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// How the update landed, read from the `luxe` a shell would run now.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
enum Outcome {
|
||||
/// It reports the new version
|
||||
Updated,
|
||||
/// `PATH` finds another copy first: the update went to one file and the shell runs another
|
||||
Shadowed { found: PathBuf, updated: PathBuf },
|
||||
/// The same copy still reports an older version: the package did not have the release yet
|
||||
NotYet { reported: String },
|
||||
/// No `luxe` on `PATH`, or none that says its version
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// Judges the result from what was found on `PATH`, the copy that ran the update, what the found
|
||||
/// one reports, and the version the update was for.
|
||||
fn outcome(found: Option<&Path>, updated: &Path, reported: Option<&str>, latest: &str) -> Outcome {
|
||||
let Some(found) = found else { return Outcome::Unknown };
|
||||
if reported.is_some_and(|reported| !update::is_newer(latest, reported)) {
|
||||
return Outcome::Updated;
|
||||
}
|
||||
let same = |a: &Path, b: &Path| {
|
||||
a.canonicalize().ok().zip(b.canonicalize().ok()).is_some_and(|(a, b)| a == b)
|
||||
};
|
||||
if !same(found, updated) {
|
||||
return Outcome::Shadowed { found: found.to_path_buf(), updated: updated.to_path_buf() };
|
||||
}
|
||||
match reported {
|
||||
Some(reported) => Outcome::NotYet { reported: reported.to_string() },
|
||||
None => Outcome::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
/// The `luxe` a shell would run now, and the outcome it shows.
|
||||
async fn installed_now(latest: &str) -> Outcome {
|
||||
let found = luxe_core::program::resolve("luxe");
|
||||
let reported = match &found {
|
||||
Some(path) => version_of(path).await,
|
||||
None => None,
|
||||
};
|
||||
let updated = std::env::current_exe().unwrap_or_default();
|
||||
outcome(found.as_deref(), &updated, reported.as_deref(), latest)
|
||||
}
|
||||
|
||||
/// The version `path --version` prints, as `luxe 0.2.0`.
|
||||
async fn version_of(path: &Path) -> Option<String> {
|
||||
let output = tokio::process::Command::new(path).arg("--version").output().await.ok()?;
|
||||
parse_version(&String::from_utf8_lossy(&output.stdout))
|
||||
}
|
||||
|
||||
/// The version in `--version` output: its last word, when that is semver.
|
||||
fn parse_version(output: &str) -> Option<String> {
|
||||
let word = update::normalize_version(output.split_whitespace().last()?);
|
||||
semver::Version::parse(word).is_ok().then(|| word.to_string())
|
||||
}
|
||||
|
||||
/// Says how it went; an update that did not take effect is an error, so a script can tell.
|
||||
fn report(outcome: Outcome) -> anyhow::Result<()> {
|
||||
match outcome {
|
||||
Outcome::Updated => println!("Updated. Start the new version with `luxe`."),
|
||||
Outcome::Unknown => println!("The update finished. `luxe --version` will confirm it."),
|
||||
Outcome::Shadowed { found, updated } => bail!(
|
||||
"the update went to {}, but `luxe` on your PATH is {}; remove that copy, or put the \
|
||||
updated one's directory first on PATH",
|
||||
updated.display(),
|
||||
found.display()
|
||||
),
|
||||
Outcome::NotYet { reported } => bail!(
|
||||
"the update finished, but `luxe --version` still says {reported}; the new release may \
|
||||
not have reached your package manager yet, so try again in a while"
|
||||
),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
69
crates/luxe-cli/src/cli/update_command/tests.rs
Normal file
69
crates/luxe-cli/src/cli/update_command/tests.rs
Normal file
@@ -0,0 +1,69 @@
|
||||
use super::*;
|
||||
|
||||
/// Two files in a temporary directory: the copy the update ran from, and another.
|
||||
fn copies() -> (tempfile::TempDir, PathBuf, PathBuf) {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let updated = dir.path().join("updated-luxe");
|
||||
let other = dir.path().join("other-luxe");
|
||||
for path in [&updated, &other] {
|
||||
std::fs::write(path, b"").expect("a stand-in binary");
|
||||
}
|
||||
(dir, updated, other)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_version_is_the_last_word_when_it_is_semver() {
|
||||
assert_eq!(parse_version("luxe 0.2.0\n").as_deref(), Some("0.2.0"));
|
||||
assert_eq!(parse_version("luxe v0.2.0").as_deref(), Some("0.2.0"));
|
||||
assert_eq!(parse_version("luxe nightly"), None);
|
||||
assert_eq!(parse_version(""), None);
|
||||
}
|
||||
|
||||
/// The new version reported, or one past it, is a finished update.
|
||||
#[test]
|
||||
fn a_copy_reporting_the_new_version_is_updated() {
|
||||
let (_dir, updated, _) = copies();
|
||||
assert_eq!(outcome(Some(&updated), &updated, Some("0.2.0"), "0.2.0"), Outcome::Updated);
|
||||
assert_eq!(outcome(Some(&updated), &updated, Some("0.2.1"), "0.2.0"), Outcome::Updated);
|
||||
}
|
||||
|
||||
/// The loop Codex CLI's users hit: the update lands in one file and the shell runs another.
|
||||
#[test]
|
||||
fn another_copy_first_on_path_is_named() {
|
||||
let (_dir, updated, other) = copies();
|
||||
let shadowed = outcome(Some(&other), &updated, Some("0.1.0"), "0.2.0");
|
||||
assert_eq!(shadowed, Outcome::Shadowed { found: other, updated });
|
||||
}
|
||||
|
||||
/// A symlink to the copy that updated is that copy, as the development install's is, so an old
|
||||
/// version there means the package was behind, not that a second copy is in the way.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_link_to_the_updated_copy_is_the_same_copy() {
|
||||
let (dir, updated, _) = copies();
|
||||
let link = dir.path().join("luxe");
|
||||
std::os::unix::fs::symlink(&updated, &link).expect("symlink");
|
||||
let behind = outcome(Some(&link), &updated, Some("0.1.0"), "0.2.0");
|
||||
assert_eq!(behind, Outcome::NotYet { reported: "0.1.0".into() });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_luxe_on_path_or_no_version_cannot_be_judged() {
|
||||
let (_dir, updated, _) = copies();
|
||||
assert_eq!(outcome(None, &updated, None, "0.2.0"), Outcome::Unknown);
|
||||
assert_eq!(outcome(Some(&updated), &updated, None, "0.2.0"), Outcome::Unknown);
|
||||
}
|
||||
|
||||
/// Only the reader's own command is ever named, and a check offers `luxe update` beside it.
|
||||
#[test]
|
||||
fn the_instructions_name_the_owners_command_or_none() {
|
||||
let check = instructions(InstallSource::Cargo, true, false);
|
||||
assert!(check.contains("luxe update") && check.contains("cargo install"), "{check}");
|
||||
let download = instructions(InstallSource::Archive, false, false);
|
||||
assert!(download.contains("download it from"), "{download}");
|
||||
let windows = instructions(InstallSource::Cargo, false, true);
|
||||
assert!(
|
||||
windows.contains("once it has exited") && windows.contains("cargo install"),
|
||||
"{windows}"
|
||||
);
|
||||
}
|
||||
@@ -481,6 +481,7 @@ script can tell a failure from an answer without reading the output.
|
||||
| `luxe loop fresh` | Reset the run's turn count; see [Autonomous runs](loop.md#start-a-run) |
|
||||
| `luxe docs [page]` | Read this guide, offline and for the installed version. `--search <words>` finds lines across every page. |
|
||||
| `luxe doctor` | Check which tools, language servers and debug adapters work |
|
||||
| `luxe update` | Update Luxe with the command for however it was installed; see [Updates](configuration.md#updates). `--check` only reports. |
|
||||
| `luxe init` | Set up a theme, a provider, the tools and the start screen, and write them to `~/.config/luxe/config.json`. `--defaults` skips the questions, `--force` starts from an empty file; see [Editing](configuration.md#editing). |
|
||||
| `luxe wire <log>` | Summarize a `LUXE_WIRE_LOG` capture; see [Troubleshooting](troubleshooting.md#see-what-is-sent-to-the-model). `--tools` breaks the tool schemas' size down per tool. |
|
||||
|
||||
@@ -555,6 +556,7 @@ words of it you have typed, like `pr` in `/diff pr 142`. A command that stays pl
|
||||
| `/auth` | Which providers you are signed in to, and how |
|
||||
| `/reload` | Re-read your config and keys without restarting |
|
||||
| `/quit` | Leave Luxe. The session is already saved. |
|
||||
| `/update` | Leave Luxe and update it, as `luxe update` does |
|
||||
|
||||
The Command Palette also lists commands with no slash form, such as **Copy message**, **Swap the
|
||||
sidebar's side** and, in a review, **Send comments**.
|
||||
@@ -844,17 +846,33 @@ This is local to your machine and on by default. Outside herdr nothing is sent.
|
||||
{ "herdr": false }
|
||||
```
|
||||
|
||||
### Update notice
|
||||
### Updates
|
||||
|
||||
Once a day, Luxe checks whether a newer release exists and says so on the start screen, with the
|
||||
command to update. Luxe never updates itself. The check sends nothing about you or your machine; the
|
||||
comparison happens locally.
|
||||
Once a day, Luxe checks whether a newer release exists, and when one does the start screen says
|
||||
*Update available · /update*. The check sends nothing about you or your machine; the comparison
|
||||
happens locally.
|
||||
|
||||
`/update`, or `luxe update` in a shell, updates Luxe with the command for however you installed
|
||||
it, showing each one before it runs:
|
||||
|
||||
| Installed with | `luxe update` runs |
|
||||
| --- | --- |
|
||||
| Cargo | `cargo install --locked --force luxe-cli` |
|
||||
| Homebrew | `brew update`, then `brew upgrade luxe` |
|
||||
|
||||
Luxe never downloads or replaces its own program; the package manager that installed it does. A
|
||||
copy your system's package manager owns is left to it, and a downloaded one points you at the
|
||||
releases page. On Windows, Luxe can't be replaced while it runs, so it prints the command to run
|
||||
once it has exited. Afterwards it checks that the `luxe` your shell finds is the new version, and
|
||||
says so if another copy earlier on your `PATH` is in the way. `luxe update --check` only reports.
|
||||
|
||||
To stop the daily check:
|
||||
|
||||
```json title="~/.config/luxe/config.json"
|
||||
{ "update": { "check": false } }
|
||||
```
|
||||
|
||||
`LUXE_UPDATE_CHECK=0` turns it off as well.
|
||||
`LUXE_UPDATE_CHECK=0` turns it off as well. `luxe update` still checks when you run it.
|
||||
|
||||
### Launchers
|
||||
|
||||
@@ -2121,8 +2139,9 @@ luxe --version
|
||||
This installs the `luxe` command. You need a recent stable Rust; [rustup](https://rustup.rs)
|
||||
installs one.
|
||||
|
||||
To update, run the same command with `--force`. Luxe checks once a day for a newer release and says
|
||||
so on the start screen; see [Update notice](configuration.md#update-notice) to turn that off.
|
||||
To update, run `luxe update`, or `/update` inside Luxe. Luxe checks once a day for a newer release
|
||||
and says so on the start screen; see [Updates](configuration.md#updates) for how it updates and how
|
||||
to turn the check off.
|
||||
|
||||
## Build from source
|
||||
|
||||
@@ -4231,7 +4250,8 @@ There is no telemetry. Luxe connects only to:
|
||||
2. Search providers and web pages, when the agent uses `web_search` or `web_fetch`, and GitHub
|
||||
when `web_fetch` clones a repository (`"tools": { "clone_repositories": false }` stops it)
|
||||
3. The models.dev catalog, to refresh model details (`LUXE_MODELS_DEV_REFRESH=0` stops it)
|
||||
4. The update check, once a day (`"update": { "check": false }` stops it)
|
||||
4. The update check, once a day (`"update": { "check": false }` stops it), and when you run
|
||||
`luxe update` or `/update`, which then runs your package manager's own update
|
||||
5. GitHub, through your own `gh`, when you, the agent or an [RPC client](rpc.md#github-writes) work
|
||||
with pull requests and issues. A client can write there only if you start it with
|
||||
`--github-writes`.
|
||||
|
||||
@@ -74,10 +74,7 @@ pub(crate) fn spawn_check(repo_root: &std::path::Path) {
|
||||
if !UpdateState::load(&path).is_stale(update::CHECK_TTL) {
|
||||
return;
|
||||
}
|
||||
let url = std::env::var("LUXE_UPDATE_URL")
|
||||
.ok()
|
||||
.filter(|value| !value.trim().is_empty())
|
||||
.unwrap_or_else(|| update::RELEASE_MANIFEST_URL.to_string());
|
||||
let url = manifest_url();
|
||||
|
||||
tokio::spawn(async move {
|
||||
// The timestamp moves whether or not the fetch worked, so an unreachable endpoint is
|
||||
@@ -93,6 +90,27 @@ pub(crate) fn spawn_check(repo_root: &std::path::Path) {
|
||||
});
|
||||
}
|
||||
|
||||
/// Asks the manifest now, whatever the cache says, and records the answer: the reader asked, as
|
||||
/// `luxe update` does, so neither the daily cadence nor the opt-out applies. The request is the
|
||||
/// same anonymous one the daily check makes.
|
||||
pub(crate) async fn check_now() -> Result<String, String> {
|
||||
let latest = fetch_latest(&manifest_url()).await?;
|
||||
let path = state_path();
|
||||
let state = UpdateState { latest: Some(latest.clone()), checked_at: now_secs() };
|
||||
if let Err(error) = state.store(&path) {
|
||||
tracing::debug!(%error, path = %path.display(), "could not cache the update check");
|
||||
}
|
||||
Ok(latest)
|
||||
}
|
||||
|
||||
/// The release manifest, with `LUXE_UPDATE_URL` as a test seam.
|
||||
fn manifest_url() -> String {
|
||||
std::env::var("LUXE_UPDATE_URL")
|
||||
.ok()
|
||||
.filter(|value| !value.trim().is_empty())
|
||||
.unwrap_or_else(|| update::RELEASE_MANIFEST_URL.to_string())
|
||||
}
|
||||
|
||||
/// Seconds since the epoch, or 0 if the clock is unreadable (which reads as "never checked").
|
||||
fn now_secs() -> u64 {
|
||||
std::time::SystemTime::now()
|
||||
@@ -230,6 +248,25 @@ mod tests {
|
||||
std::env::remove_var("LUXE_UPDATE_CHECK");
|
||||
}
|
||||
|
||||
/// `luxe update` asks whatever the cadence and the opt-out say, since the reader asked, and
|
||||
/// what it learns is cached, so the start screen agrees with it.
|
||||
#[tokio::test]
|
||||
async fn an_asked_for_check_ignores_the_opt_out_and_caches_the_answer() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let cache = dir.path().join("update.json");
|
||||
std::env::set_var("LUXE_UPDATE_PATH", &cache);
|
||||
std::env::set_var("LUXE_UPDATE_CHECK", "0");
|
||||
std::env::set_var(
|
||||
"LUXE_UPDATE_URL",
|
||||
serve_once(r#"{"tag_name":"v99.0.0"}"#, "200 OK").await,
|
||||
);
|
||||
assert_eq!(check_now().await.as_deref(), Ok("99.0.0"));
|
||||
assert_eq!(UpdateState::load(&cache).latest.as_deref(), Some("99.0.0"));
|
||||
for name in ["LUXE_UPDATE_PATH", "LUXE_UPDATE_CHECK", "LUXE_UPDATE_URL"] {
|
||||
std::env::remove_var(name);
|
||||
}
|
||||
}
|
||||
|
||||
/// Both manifest shapes resolve, so moving off the GitHub API later is a URL change rather
|
||||
/// than a code change.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user