Skip to content

save Package.resolved with a trailing newline #3822

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

Merged
merged 1 commit into from
Oct 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Sources/PackageGraph/PinsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,20 @@ fileprivate struct PinsStorage {
return
}

let data: Data
var data: Data
if toolsVersion >= .v5_6 {
let container = try V2(pins: pins, mirrors: mirrors)
data = try self.encoder.encode(container)
} else {
let container = try V1(pins: pins, mirrors: mirrors)
data = try self.encoder.encode(container)
}
#if !os(Windows)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason the Windows one shouldn't add with \r\n?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could, but i am not sure if a trailing newline is a convention on Windows

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point — anyway it doesn't make a lot of difference provided that they work fine there without it. No reason not to merge, it would just be nicer to avoid the #if if there was a stock way of appending a platform line separator.

// rdar://83646952: add newline for POSIXy systems
if data.last != 0x0a {
data.append(0x0a)
}
#endif
try self.fileSystem.writeFileContents(self.path, data: data)
}
}
Expand Down