Report tag prerequisites in Rust dry runs

This commit is contained in:
Dandaedre 2026-09-17 02:03:21 +02:00
parent e73571a67f
commit 9416fd2f48
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
3 changed files with 39 additions and 6 deletions

View File

@ -18,6 +18,8 @@ Current Rust milestone: inspection, metadata, preparation, host verification, Cr
Progress tracking: check a task only when the Rust behavior is implemented and locally verified. Keep phase gates open until their full fixture/parity criteria pass. The Python baseline has 45 passing tests and two opt-in tests skipped. CI runs Cargo tests only; Cross and live Gitea tests are deferred. Next work: isolated preparation-push test, broader parity fixtures, and offline publication edge cases.
Parity note: Python and Rust `target_test_project --dry-run --stop-after verify` both report the missing local release tag and exit nonzero. The Rust dry run now reports this as a prerequisite without creating a tag. Python and Rust metadata-stage runs both succeed on the fixture. Output formatting differs; full fixture parity remains open.
Work in small, testable phases. Commit migration work in coherent increments.
---

View File

@ -221,13 +221,18 @@ pub fn run(args: Cli) -> Result<(), Error> {
&& args
.stop_after
.is_none_or(|stage| stage.order() >= Stage::Binstall.order());
let (problems, engine) = build::prerequisites(
let (mut problems, engine) = build::prerequisites(
&checkout.root,
&config,
needs_cross,
needs_binstall,
&runner,
);
if args.dry_run {
if let Err(error) = project::validate_checkout_tag(&checkout.root, &tag, &runner) {
problems.push(error.to_string());
}
}
for problem in &problems {
println!("Prerequisite: {problem}");
}

View File

@ -31,15 +31,15 @@ pub struct Gitea {
impl Gitea {
pub fn new(repository: &str, token_env: &str) -> Result<Self, Error> {
let token = env::var(token_env)
.ok()
.filter(|s| !s.is_empty())
.ok_or_else(|| Error(format!("Set {token_env} before publishing.")))?;
if !repository.starts_with("https://") {
return Err(Error(
"Authenticated Gitea publishing requires HTTPS.".into(),
));
}
let token = env::var(token_env)
.ok()
.filter(|s| !s.is_empty())
.ok_or_else(|| Error(format!("Set {token_env} before publishing.")))?;
Self::with_token(repository, &token)
}
@ -418,9 +418,35 @@ mod tests {
handle.join().unwrap();
}
#[test]
fn missing_or_mismatched_remote_tag_stops_before_release_mutation() {
for (status, body, expected) in [
(404, "{}", "missing"),
(200, r#"{"commit":{"sha":"other"}}"#, "differs"),
] {
let (host, handle) = server(vec![Reply {
method: "GET",
path: "/api/v1/repos/team/demo/tags/v0.1.0",
status,
body,
}]);
let api = Gitea::with_token(&format!("{host}/team/demo"), "test-token").unwrap();
let error = api
.ensure_release("v0.1.0", "abc", false, false)
.unwrap_err()
.to_string();
assert!(error.contains(expected), "{error}");
assert_eq!(handle.join().unwrap().len(), 1);
}
}
#[test]
fn encodes_tag_and_requires_https() {
assert_eq!(encode("v1.0+build"), "v1.0%2Bbuild");
assert!(Gitea::new("http://example.com/team/demo", "GITEA_TOKEN").is_err());
assert!(Gitea::new("http://example.com/team/demo", "GITEA_TOKEN")
.err()
.unwrap()
.to_string()
.contains("HTTPS"));
}
}