utopia-ia/elffuss-braid public
Changesets · Branches · Tags · Compare
| Changeset | f094e2b508eeab2f99ca86f5dc27533e55f465be8ae504d387c732341054f51c |
|---|---|
| Author | KikoCis <KikoCis@users.noreply.github.com> · 2026-10-21 15:55 +02:00 |
| Committer | KikoCis <KikoCis@users.noreply.github.com> · 2026-10-21 15:55 +02:00 |
| Parents | bf223502faa3 |
3 files changed
modified crates/cli/src/main.rs +8 −0
| @@ -476,6 +476,14 @@ | ||
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | fn run(cli: &Cli) -> Result<ExitCode> { |
| 479 | + if cli.agent == verify::AGENT | |
| 480 | + && !matches!( | |
| 481 | + cli.command, | |
| 482 | + Command::Verify(_) | Command::VerifyWatchdog { .. } | |
| 483 | + ) | |
| 484 | + { | |
| 485 | + eprintln!("braid: warning: {}", verify::AGENT_WARNING); | |
| 486 | + } | |
| 479 | 487 | match &cli.command { |
| 480 | 488 | Command::Init { dir } => init(cli, dir.as_deref()), |
| 481 | 489 | Command::Agents { action } => agents::agents(cli, action), |
modified crates/cli/src/verify.rs +3 −0
| @@ -48,6 +48,9 @@ | ||
| 48 | 48 | /// and the reverts it makes and lands. |
| 49 | 49 | pub(crate) const AGENT: &str = "braid-verify"; |
| 50 | 50 | |
| 51 | +/// What braid says when someone else acts as [`AGENT`]. | |
| 52 | +pub(crate) const AGENT_WARNING: &str = "the agent braid-verify (--agent or BRAID_AGENT) is the name braid verify records its own work under: verify takes a revert made under that name for one of its own, never reverts it, and counts it against --max-reverts-per-hour"; | |
| 53 | + | |
| 51 | 54 | /// The hidden subcommand that watches a test run for braid going away. |
| 52 | 55 | pub(crate) const WATCHDOG: &str = "__verify-watchdog"; |
| 53 | 56 |
modified crates/cli/tests/verify.rs +13 −0
| @@ -744,3 +744,16 @@ | ||
| 744 | 744 | test.wait().unwrap(); |
| 745 | 745 | std::fs::remove_dir_all(&kept).unwrap(); |
| 746 | 746 | } |
| 747 | + | |
| 748 | +#[test] | |
| 749 | +fn acting_as_braid_verify_is_warned_about() { | |
| 750 | + let r = Repo::new(); | |
| 751 | + let warned = |args: &[&str], envs: &[(&str, &str)]| { | |
| 752 | + let out = braid_with(&r.dir, args, envs); | |
| 753 | + assert!(out.status.success(), "{args:?}"); | |
| 754 | + String::from_utf8_lossy(&out.stderr).contains("warning: the agent braid-verify") | |
| 755 | + }; | |
| 756 | + assert!(warned(&["--agent", "braid-verify", "refs"], &[])); | |
| 757 | + assert!(warned(&["refs"], &[("BRAID_AGENT", "braid-verify")])); | |
| 758 | + assert!(!warned(&["refs"], &[])); | |
| 759 | +} |