-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Omit unchanged options from config.toml in configure.py
#108632
Conversation
r? @ozkanonur (rustbot has picked a reviewer for you, use r? to override) |
a1173d2
to
0035e53
Compare
src/bootstrap/configure.py
Outdated
# only blocks with an uncommented line will be output | ||
block = [] | ||
has_non_comment = False | ||
for line in targets[target]: | ||
f.write(line + "\n") | ||
block.append(line) | ||
if len(line) == 0: | ||
if has_non_comment: | ||
for l in block: | ||
f.write(l + "\n") | ||
block = [] | ||
has_non_comment = False | ||
continue | ||
if not line.startswith('#'): | ||
has_non_comment = True | ||
else: | ||
# only blocks with an uncommented line will be output | ||
block = [] | ||
has_non_comment = False | ||
for line in sections[section]: | ||
f.write(line + "\n") | ||
block.append(line) | ||
if len(line) == 0: | ||
if has_non_comment: | ||
for l in block: | ||
f.write(l + "\n") | ||
block = [] | ||
has_non_comment = False | ||
continue | ||
if not line.startswith('#'): | ||
has_non_comment = True |
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.
can you avoid duplicating this please? maybe with a helper function?
src/bootstrap/configure.py
Outdated
@@ -494,11 +494,35 @@ def configure_top_level_key(lines, top_level_key, value): | |||
for section in section_order: | |||
if section == 'target': | |||
for target in targets: | |||
# only blocks with an uncommented line will be output | |||
block = [] | |||
has_non_comment = False |
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.
has_non_comment = False | |
is_comment = True |
src/bootstrap/configure.py
Outdated
block.append(line) | ||
if len(line) == 0: | ||
if has_non_comment: | ||
for l in block: | ||
f.write(l + "\n") | ||
block = [] | ||
has_non_comment = False | ||
continue | ||
if not line.startswith('#'): | ||
has_non_comment = True | ||
else: | ||
# only blocks with an uncommented line will be output | ||
block = [] | ||
has_non_comment = False |
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.
comment check can be simplified with:
block.append(line) | |
if len(line) == 0: | |
if has_non_comment: | |
for l in block: | |
f.write(l + "\n") | |
block = [] | |
has_non_comment = False | |
continue | |
if not line.startswith('#'): | |
has_non_comment = True | |
else: | |
# only blocks with an uncommented line will be output | |
block = [] | |
has_non_comment = False | |
block.append(line) | |
if len(line) == 0: | |
if not is_comment: | |
for l in block: | |
f.write(l + "\n") | |
block = [] | |
is_comment = True | |
continue | |
is_comment = line.startswith('#'): | |
else: | |
# only blocks with an uncommented line will be output | |
block = [] | |
is_comment = True |
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.
I don't think this will work if the comment is the last line in the block e.g.:
# some text
some_config=true
# some more text
end of block
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.
I haven't tested it. Just tried to reverse the idea of has_non_comment
with is_comment
and simplify the following block
if not line.startswith('#'):
has_non_comment = True
with
is_comment = line.startswith('#'):
to make it easier to read.
Maybe I mischanged something, is it not possible to write it that way?
@rustbot author |
should have fixed all the issues listed, let me know if i should squash |
The code look much better. But it fails the pipeline unfortunately https://github.com/rust-lang/rust/actions/runs/4315278739/jobs/7529435117#step:26:1670 (and yes, please squash the commits at the end) |
been looking at this, can't tell what is wrong builds just fine on both my win 11 install and on my ubuntu 22.04 install. |
It's not the build thats failing.
You can force push to PR and re-trigger the pipelines to see if the error actually related with your PR. If it does, you might miss something while refactoring(because it pipelines passed before) |
This comment has been minimized.
This comment has been minimized.
21f930c
to
a2d1368
Compare
…where it is not default
a2d1368
to
00f98e6
Compare
ah looks like an or turned into an and and it broke everything :) it's actually fixed now |
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.
LGTM
@bors r+ rollup |
…anonur Omit unchanged options from config.toml in `configure.py` Leaves section tags, but removes options that are unchanged. Change in `config.toml.example` is to prevent comments from sneaking in by being directly after a section tag closes rust-lang#108612
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#108627 (Properly colorize multi-part suggestions in the same line) - rust-lang#108632 (Omit unchanged options from config.toml in `configure.py`) - rust-lang#108715 (Remove unclosed_delims from parser) - rust-lang#108723 (rustdoc: function signature search with traits in `where` clause) - rust-lang#108724 (field is not used outside the crate) - rust-lang#108734 (rustdoc: Note in a type's layout/size if it is uninhabited) - rust-lang#108736 (Remove `allow(potential_query_instability)` from `ast_passes`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Leaves section tags, but removes options that are unchanged.
Change in
config.toml.example
is to prevent comments from sneaking in by being directly after a section tagcloses #108612