Skip to main content

lock_verify_or_generate

Function lock_verify_or_generate 

Source
pub fn lock_verify_or_generate(
    lockfile: &Path,
    program: &str,
    verify_args: &[&str],
    generate_args: &[&str],
    cwd: &Path,
    timeout: Duration,
) -> Result<()>
Expand description

Lockfile enforcement for ecosystems whose “sync” command rewrites source manifests.

cargo generate-lockfile re-resolves every dependency and overwrites Cargo.lock; go mod tidy edits both go.mod and go.sum and can drop requirements. Running either as a precondition for deletion would silently modify tracked source files, which contradicts the lockfile-safety guarantee. So:

  • lockfile present → run the read-only verify_args (never writes)
  • lockfile absent → run generate_args, since a lockfile must exist for restore