MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / lockfile

Function lockfile

atomic-cli/tests/it/git_import_generated_modify_test.rs:74–86  ·  view source on GitHub ↗

A deterministic multi-package lockfile. `packages` drives both the line count and the byte count. `bump_from` rewrites the versions of every package at or after that index, so the follow-up commit produces IN-PLACE replace hunks scattered mid-file — the shape that corrupted the staged render (the real Cargo.lock diff replaced lines ~1210-1220 across 14 hunks while the graph held the file as one wh

(packages: usize, bump_from: usize)

Source from the content-addressed store, hash-verified

72/// staged render (the real Cargo.lock diff replaced lines ~1210-1220 across
73/// 14 hunks while the graph held the file as one whole-content vertex).
74fn lockfile(packages: usize, bump_from: usize) -> Vec<u8> {
75 let mut content = String::from("# This file is automatically @generated by Cargo.\n");
76 content.push_str("version = 3\n\n");
77 for package in 0..packages {
78 let major = if package >= bump_from { 2 } else { 1 };
79 content.push_str(&format!(
80 "[[package]]\nname = \"dep-{package}\"\nversion = \"{major}.{}.0\"\nsource = \"registry+https://github.com/rust-lang/crates.io-index\"\nchecksum = \"aaaaaaaa{package:04}bbbbbbbb{package:04}cccccccc{package:04}dddddddd{package:04}\"\ndependencies = [\n \"dep-{}\",\n]\n\n",
81 package % 10,
82 package.saturating_sub(1)
83 ));
84 }
85 content.into_bytes()
86}
87
88#[test]
89fn git_import_records_a_modified_generated_file_with_exact_content() {

Calls

no outgoing calls

Tested by

no test coverage detected