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

[devtools] add clang-format.py #6790

Merged
merged 2 commits into from
Oct 23, 2015

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Oct 9, 2015

This will add a python convenience wrapper for clang-format. The python code includes a list with tested versions (tested_versions) which can easily be updated in the future.

[ci skip]

@jonasschnelli
Copy link
Contributor

Not sure if possible: a script that only clang-formats changed/added code (would require some clever git operations) would be nice.

@maflcko
Copy link
Member Author

maflcko commented Oct 9, 2015

@jonasschnelli Not sure if clang-format-diff.py is what you are looking for.

@paveljanik
Copy link
Contributor

After looking at the amount of changes clang-format generates and actually looking at such changes and looking at our release process (releasing 0.10, 0.11, ...), I think it doesn't make sense to apply the formatting in one shot for all the source files.
It only has sense for formatting new files and (maybe) for very stable files, like primites/* etc.

And as written above, I do not think the wrapper (in fact, -i and "tested" version check) is needed at all.

@maflcko
Copy link
Member Author

maflcko commented Oct 11, 2015

@paveljanik I think it doesn't make sense to apply the formatting in one shot for all the source files.

I think we all agree on this.

@paveljanik I do not think the [...] "tested" version check is needed at all.

How would one verify a format PR when different versions produce different output? Also, it may be useful the extend the clang-format.py to skip git subtrees et al. (c.f. sipa@a126129#diff-6ca10bb3f43dbe234b1fce27929ce0d4R10 ).

@laanwj
Copy link
Member

laanwj commented Oct 13, 2015

Code review ACK, although I'm not sure I see when this should be used.

Needs mention in contrib/devtools/README.md

@sipa
Copy link
Member

sipa commented Oct 13, 2015 via email

@paveljanik
Copy link
Contributor

It should definitely be used when committing new files...

@maflcko maflcko force-pushed the MarcoFalke-2015-clangFormatWrapper branch 2 times, most recently from c2cbfec to 8df2a9c Compare October 15, 2015 15:40
@maflcko maflcko force-pushed the MarcoFalke-2015-clangFormatWrapper branch 2 times, most recently from 65a293f to 37772d1 Compare October 15, 2015 18:02
@maflcko
Copy link
Member Author

maflcko commented Oct 16, 2015

@laanwj Done.
@sipa I have tested 3.6.{0,1,2} and they all produce the same output, so I have added them to tested_versions.

@laanwj
Copy link
Member

laanwj commented Oct 23, 2015

I wonder whether a solution could be to include a small snippet of representative unformatted code, and have the wrapper script check whether it results in the expected output?

I like this idea a lot.

@laanwj laanwj merged commit 8c15f33 into bitcoin:master Oct 23, 2015
laanwj added a commit that referenced this pull request Oct 23, 2015
8c15f33 [trivial] Update contrib/devtools/README.md (MarcoFalke)
338f62f [devtools] add clang-format.py (MarcoFalke)
@maflcko maflcko deleted the MarcoFalke-2015-clangFormatWrapper branch October 23, 2015 10:40
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants