Skip to content

check: Use --text when potentially diffing generated files #947

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 2 commits into from
Sep 18, 2024

Conversation

PIG208
Copy link
Member

@PIG208 PIG208 commented Sep 17, 2024

The diffs generated from running tools/check build_runner were not detected. See comment: #904 (comment)

We normally exclude diffs from generated files through our .gitattributes configurations. This happens to git --quiet -- [<path>...] too. -a/--text allows us to include those files regardless.

The diffs generated from running `tools/check build_runner` were not
detected.  See comment:
zulip#904 (comment)

We normally exclude diffs from generated files through our
`.gitattributes` configurations.  This happens to `git --quiet --
[<path>...]` too.  -a/--text allows us to include those files
regardless.

Signed-off-by: Zixuan James Li <[email protected]>
@PIG208 PIG208 added a-tools Our own development tooling, scripts, and infrastructure maintainer review PR ready for review by Zulip maintainers labels Sep 17, 2024
@PIG208 PIG208 requested a review from chrisbobbe September 17, 2024 20:59
@chrisbobbe
Copy link
Collaborator

LGTM, marking for Greg's review.

@chrisbobbe chrisbobbe added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Sep 17, 2024
@chrisbobbe chrisbobbe assigned gnprice and unassigned chrisbobbe Sep 17, 2024
@chrisbobbe chrisbobbe requested a review from gnprice September 17, 2024 21:40
Normally in scripts I prefer using long options, to make
the meaning more explicit for the reader.

But this particular option `--text` on `git diff` has a pretty
confusing name: it sounds like it potentially means "only look
at text files", which is the opposite of what it turns out to mean.
Plus its meaning really isn't about "text" (vs "binary") at all: the
files we set the `-diff` attribute on are mostly just as textual as
any others, just boring for diffs because they're generated.

So use the short name `-a` instead.  That suggests "all", which is
exactly the right idea.

Also expand the comment a bit.
@gnprice
Copy link
Member

gnprice commented Sep 18, 2024

Aha, that diagnosis makes sense! Thanks @PIG208 for investigating and fixing this.

One thing that likely misled me, when I wrote the build_runner suite in the first place and was testing it locally, is that I have a .git/info/attributes which partly overrides the .gitattributes:

$ cat .git/info/attributes
*.g.dart diff
lib/host/*.g.dart -diff

In particular the diffs to our json_serializable-generated files under lib/api/ are fairly low-noise, and in review I like to see them to know what the deserialization code is actually doing.

So that would have caused the existing version of this code to work fine for me on those files, even while it didn't in CI or for other people locally.


The changes all look good; thanks for the nice commit message. Merging, with an added NFC commit on top.

@gnprice gnprice merged commit ecc219e into zulip:main Sep 18, 2024
1 check passed
@PIG208 PIG208 deleted the pr-quiet branch October 8, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-tools Our own development tooling, scripts, and infrastructure integration review Added by maintainers when PR may be ready for integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants