Avoid writing invalid PEP 723 scripts on tool.uv.sources (#6706)

## Summary

We were writing empty lines between the dependencies and the
`tool.uv.sources` table, which led to the `/// script` tag being
unclosed and thus not recognized.

Closes https://github.com/astral-sh/uv/issues/6700.
This commit is contained in:
Charlie Marsh 2024-08-27 13:49:08 -04:00 committed by GitHub
parent a8f4e08d5b
commit 8d466db080
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 20 deletions

View file

@ -350,13 +350,12 @@ fn serialize_metadata(metadata: &str) -> String {
output.push('\n');
for line in metadata.lines() {
if line.is_empty() {
output.push('\n');
} else {
output.push_str("# ");
output.push('#');
if !line.is_empty() {
output.push(' ');
output.push_str(line);
output.push('\n');
}
output.push('\n');
}
output.push_str("# ///");