[devtools] add clang-format.py #6790

pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:MarcoFalke-2015-clangFormatWrapper changing 2 files +82 −6
  1. MarcoFalke commented at 2:23 pm on October 9, 2015: member

    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]

  2. jonasschnelli commented at 2:27 pm on October 9, 2015: contributor
    Not sure if possible: a script that only clang-formats changed/added code (would require some clever git operations) would be nice.
  3. MarcoFalke commented at 2:29 pm on October 9, 2015: member
    @jonasschnelli Not sure if clang-format-diff.py is what you are looking for.
  4. paveljanik commented at 2:08 pm on October 10, 2015: 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.

  5. MarcoFalke commented at 1:12 pm on October 11, 2015: member

    @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. https://github.com/sipa/bitcoin/commit/a1261296e48967b3236053d3435a3f521898df2f#diff-6ca10bb3f43dbe234b1fce27929ce0d4R10 ).

  6. laanwj commented at 9:38 am on October 13, 2015: member

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

    Needs mention in contrib/devtools/README.md

  7. sipa commented at 9:43 am on October 13, 2015: member
    Earlier reasons to not use clang-format was that its output changed, even between several “versions” of clang-format-3.5. 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?
  8. paveljanik commented at 1:39 pm on October 13, 2015: contributor
    It should definitely be used when committing new files…
  9. MarcoFalke force-pushed on Oct 15, 2015
  10. MarcoFalke force-pushed on Oct 15, 2015
  11. [devtools] add clang-format.py 338f62f701
  12. MarcoFalke force-pushed on Oct 15, 2015
  13. MarcoFalke force-pushed on Oct 15, 2015
  14. [trivial] Update contrib/devtools/README.md 8c15f33d15
  15. MarcoFalke force-pushed on Oct 15, 2015
  16. MarcoFalke commented at 10:28 am on October 16, 2015: member
    @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.
  17. laanwj added the label Dev Scripts on Oct 23, 2015
  18. laanwj commented at 8:41 am on October 23, 2015: member

    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.

  19. laanwj merged this on Oct 23, 2015
  20. laanwj closed this on Oct 23, 2015

  21. laanwj referenced this in commit fa1d252e82 on Oct 23, 2015
  22. MarcoFalke deleted the branch on Oct 23, 2015
  23. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me