-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve lockfile top comment #6181
Preserve lockfile top comment #6181
Conversation
r? @matklad (rust_highfive has picked a reviewer for you, use r? to override) |
WDYT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow that was quite easy, thanks!
src/cargo/ops/lockfile.rs
Outdated
@@ -43,6 +43,15 @@ pub fn write_pkg_lockfile(ws: &Workspace, resolve: &Resolve) -> CargoResult<()> | |||
|
|||
let mut out = String::new(); | |||
|
|||
if let Ok(ref orig) = orig { | |||
if let Some(first_line) = orig.lines().into_iter().next() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this perhaps be...
if let Ok(orig) = &orig {
for line in org.lines().take_while(|line| line.starts_with("#")) {
out.push_str(line);
out.push_str("\n");
}
}
That way we can preserve multiline comments if necessary as well
tests/testsuite/update.rs
Outdated
println!("loaded Cargo.lock contents:\n{}", lockfile2); | ||
|
||
let first_line = lockfile2.lines().into_iter().next().unwrap(); | ||
assert!(first_line == "# @generated"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of just asserting the first line, could this assert that the lock files are byte-for-byte equal the most recent lockfile does indeed contain @generated
?
@bors: r+ |
📌 Commit 32fbfe3 has been approved by |
…richton Preserve lockfile top comment Refs #6180
☀️ Test successful - status-appveyor, status-travis |
Refs #6180