Test atomic preparation push against disposable Git remote

This commit is contained in:
Dandaedre 2026-09-17 02:06:44 +02:00
parent 296abe38ea
commit 55bff4937d
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
3 changed files with 72 additions and 4 deletions

View File

@ -14,9 +14,9 @@ The Python implementation remains the behavioral oracle until the Rust replaceme
- Defer live API release tests until a disposable token is provided.
- Use the small `target_test_project` submodule for fast build and cross-target experiments.
Current Rust milestone: inspection, metadata, preparation, host verification, Cross build, packaging, Gitea publication, anonymous downloads, and isolated cargo-binstall orchestration are implemented. Gitea paths pass local HTTP mock tests; live publication and real cargo-binstall installation still need a disposable token. Preparation has disposable Git tests for dry-run, commit, tag safety, and destination refusal; atomic push still needs an isolated integration test. The tiny fixture built and packaged all three default targets locally.
Current Rust milestone: inspection, metadata, preparation, host verification, Cross build, packaging, Gitea publication, anonymous downloads, and isolated cargo-binstall orchestration are implemented. Gitea paths pass local HTTP mock tests; live publication and real cargo-binstall installation still need a disposable token. Preparation has disposable Git tests for dry-run, commit, tag safety, destination refusal, and an atomic branch/tag push to a local bare remote. The tiny fixture built and packaged all three default targets locally.
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.
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: 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.
@ -378,7 +378,7 @@ Test-only as useful:
- [x] Existing correct tag is validated, not moved.
- [x] `--push-preparation` requires required predecessor flags.
- [x] Verify push destination matches release repository.
- [ ] Push branch + tag atomically where current behavior expects it.
- [x] Push branch + tag atomically where current behavior expects it.
- [x] Never force push.
### Dry-run

View File

@ -1,6 +1,6 @@
# Rust Binstall Publisher
> Rust migration status: the Rust binary supports inspection, metadata repair, repository preparation, host check/test, Cross builds, local packaging, Gitea release/upload, anonymous artifact verification, and isolated cargo-binstall verification. The Gitea and download paths have local HTTP mock tests; a live disposable release and real cargo-binstall install still need a token. Preparation's remote push path still needs an isolated integration test. The Python worker remains the proven publication reference until those parity gates pass.
> Rust migration status: the Rust binary supports inspection, metadata repair, repository preparation, host check/test, Cross builds, local packaging, Gitea release/upload, anonymous artifact verification, and isolated cargo-binstall verification. The Gitea and download paths have local HTTP mock tests; a live disposable release and real cargo-binstall install still need a token. Preparation's atomic branch/tag push is tested against a disposable local Git remote. The Python worker remains the proven publication reference until the remaining parity gates pass.
Inspect locally with `cargo run -- target_test_project --stop-after inspect`. Validate metadata with `cargo run -- target_test_project --stop-after metadata`; add `--dry-run` to preview proposed repairs or `--fix-metadata` to write them. Preview repository changes with `cargo run -- target_test_project --prepare-repo --dry-run`. Use `--commit-preparation`, `--create-tag`, and `--push-preparation` only when those Git writes are intended. Run host checks with `cargo run -- target_test_project --stop-after verify`. Build and package locally with `--stop-after package` once Cross and a container backend are available. Run the Rust checks with `cargo fmt --check`, `cargo clippy --all-targets --all-features -- -D warnings`, and `cargo test --all`. Live Gitea tests are deferred until a disposable token is available.

View File

@ -656,4 +656,72 @@ mod tests {
assert_eq!(fs::read_to_string(root.join("Cargo.toml")).unwrap(), before);
assert!(!root.join("Cross.toml").exists());
}
#[cfg(unix)]
#[test]
fn authorized_preparation_pushes_branch_and_tag_atomically() {
use std::os::unix::fs::PermissionsExt;
let (temp, project, config, runner) = fixture();
let root = temp.path();
let transport = tempfile::tempdir().unwrap();
let bare = transport.path().join("remote.git");
fs::create_dir(&bare).unwrap();
runner
.output("git", &["init", "--bare", "-q"], &bare)
.unwrap();
let ssh = transport.path().join("local-ssh");
fs::write(
&ssh,
format!("#!/bin/sh\nexec git-receive-pack '{}'\n", bare.display()),
)
.unwrap();
fs::set_permissions(&ssh, fs::Permissions::from_mode(0o700)).unwrap();
runner
.output(
"git",
&["config", "core.sshCommand", ssh.to_str().unwrap()],
root,
)
.unwrap();
runner
.output(
"git",
&[
"remote",
"add",
"origin",
"ssh://git@example.org/team/demo.git",
],
root,
)
.unwrap();
run(
root,
&project,
&config,
"https://example.org/team/demo",
Options {
tag: "v0.1.0",
image_tag: None,
dry_run: false,
commit: true,
create_tag: true,
push: true,
},
&runner,
)
.unwrap();
let local = runner.text("git", &["rev-parse", "HEAD"], root).unwrap();
let remote = runner
.text("git", &["rev-parse", "refs/heads/main"], &bare)
.unwrap();
assert_eq!(local, remote);
assert_eq!(
runner
.text("git", &["rev-parse", "refs/tags/v0.1.0^{commit}"], &bare)
.unwrap(),
local
);
}
}