Skip to content

Commit b569d5f

Browse files
committed
Bug 1982798 - Prevent extraneous empty lines from being added to Cargo.toml when regenerating it. r=tobyp
It's a simple fix but it took me some time to fully understand why this is happening. `tomlkit.TOMLFile.read()` preserves whitespaces (including empty lines) when parsing a TOML file (so it can reproduce them if it needs to turn the `TOMLFile` into a string). However, our template adds two line breaks at the end of the `[features]` section (to separate it from the following `[workspace]` section). Which are then reproduced endlessly. I'm not entirely sure why it started happening at the time it did, but I suspect this might have something to do with python-poetry/tomlkit#421 or python-poetry/tomlkit#422 (although I'm not 100% certain since it doesn't entirely match what I saw when I was fiddling with the tomlkit source code to investigate this). Both these changes shipped in tomlkit 0.13.3 which released in early June, which is a couple of weeks before this issue started happening. Anyway, the right thing to do in our case seems to strip the extra line breaks since we already take care of adding them in the template. Differential Revision: https://phabricator.services.mozilla.com/D260963 --HG-- extra : amend_source : 4e9a682977b07aca8162951e5ce170534dc7f1f3
1 parent 656bc06 commit b569d5f

2 files changed

Lines changed: 5 additions & 59 deletions

File tree

python/rocbuild/rocbuild/rust.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,11 @@ def regen_toml_files(command_context, workspace):
506506
dependencies="\n".join(workspace_dependencies),
507507
target_dependencies=target_deps.strip(),
508508
members=workspace_members,
509-
features=tomlkit.dumps(features),
509+
# tomlkit preserves the line breaks that separate the
510+
# `[features]` and `[workspace]` sections, but since we already
511+
# have them in the template we need to strip them out so we
512+
# don't end up with extraneous empty lines.
513+
features=tomlkit.dumps(features).strip(),
510514
patches=workspace_patches,
511515
).strip()
512516
+ "\n"

rust/Cargo.toml

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,6 @@ description = "Thunderbird extensions to mozilla-central-workspace-hack"
88
gkrust = []
99
gkrust-gtest = ["gkrust"]
1010

11-
12-
13-
14-
15-
16-
17-
18-
19-
20-
21-
22-
23-
24-
25-
26-
27-
28-
29-
30-
31-
32-
33-
34-
35-
36-
37-
38-
39-
40-
41-
42-
43-
44-
45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
55-
56-
57-
58-
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-
6911
[workspace]
7012
members = ['xpcom_async', 'moz_http', 'gkrust', 'ews_xpcom', 'gtest', 'sys_tray', 'mailnews_ui_glue']
7113

0 commit comments

Comments
 (0)