Skip to content
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

x.py fmt: logic for "which files changed" is broken when there are no changes #130147

Closed
RalfJung opened this issue Sep 9, 2024 · 6 comments · Fixed by #130161
Closed

x.py fmt: logic for "which files changed" is broken when there are no changes #130147

RalfJung opened this issue Sep 9, 2024 · 6 comments · Fixed by #130161
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@RalfJung
Copy link
Member

RalfJung commented Sep 9, 2024

When I run ./x.py fmt in a clean checkout, I get the following:

fmt: formatted 5534 modified files

If I now change a single file manually, it says instead:

fmt: formatted modified file library/core/src/ptr/mod.rs

Cc @rust-lang/bootstrap

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 9, 2024
@onur-ozkan onur-ozkan added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 9, 2024
@ibilalkayy
Copy link

I modified the same mod.rs file and got this kind of result.

I want to know what is the problem that you want to solve. I didn't understand from this issue that you raised.

erro

@RalfJung
Copy link
Member Author

RalfJung commented Sep 9, 2024

I want to know what is the problem that you want to solve

  • Put your repo into a state where it is entirely in sync with upstream master
  • run ./x.py fmt

That should only format the files that changed, which is 0 files. Instead it formats >5000 files.

@RalfJung
Copy link
Member Author

It's not just "no changes" where this case hits, I've also now hit this in a branch that does have changes compared to master. Not sure how to reproduce that.

@ibilalkayy
Copy link

I have synced with the upstream master but it showing me all the files.

again

@Kobzol
Copy link
Contributor

Kobzol commented Sep 10, 2024

(Note that this issue is not fixed yet, it needs #130161 to be merged first).

@ibilalkayy
Copy link

Thank you, for letting me know!

@bors bors closed this as completed in ff4b3d4 Sep 11, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 11, 2024
Rollup merge of rust-lang#130161 - onur-ozkan:fmt-changed-files, r=Kobzol,RalfJung

refactor merge base logic and fix `x fmt`

When remote upstream is not configured, using [get_git_modified_files](https://github.com/rust-lang/rust/blob/38e3a5771cefc9362976a605549f8b04d5707311/src/tools/build_helper/src/git.rs#L114) to find modified files fails because [get_rust_lang_rust_remote](https://github.com/rust-lang/rust/blob/38e3a5771cefc9362976a605549f8b04d5707311/src/tools/build_helper/src/git.rs#L46-L48) can not resolve "rust-lang/rust" from the git output. The changes in this PR makes bootstrap to find the latest bors commit, treating it as the "closest upstream commit" so that the change tracker logic can use it to find the diffs.

In addition, [skips formatting](rust-lang@e392454) if there are no modified files.

Fixes rust-lang#130147
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants