mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Preserve multiline top comments
This commit is contained in:
parent
0cdb780345
commit
ce40ab87c8
@ -43,12 +43,10 @@ pub fn write_pkg_lockfile(ws: &Workspace, resolve: &Resolve) -> CargoResult<()>
|
|||||||
|
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
|
|
||||||
if let Ok(ref orig) = orig {
|
if let Ok(orig) = &orig {
|
||||||
if let Some(first_line) = orig.lines().into_iter().next() {
|
for line in orig.lines().take_while(|line| line.starts_with("#")) {
|
||||||
if first_line.starts_with("#") {
|
out.push_str(line);
|
||||||
out.push_str(first_line);
|
out.push_str("\n");
|
||||||
out.push_str("\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,6 +383,7 @@ fn preserve_top_comment() {
|
|||||||
|
|
||||||
let mut lockfile = p.read_file("Cargo.lock");
|
let mut lockfile = p.read_file("Cargo.lock");
|
||||||
lockfile.insert_str(0, "# @generated\n");
|
lockfile.insert_str(0, "# @generated\n");
|
||||||
|
lockfile.insert_str(0, "# some other comment\n");
|
||||||
println!("saving Cargo.lock contents:\n{}", lockfile);
|
println!("saving Cargo.lock contents:\n{}", lockfile);
|
||||||
|
|
||||||
p.change_file("Cargo.lock", &lockfile);
|
p.change_file("Cargo.lock", &lockfile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user