Node: [Internal] clang-format the whole repo

Created on 6 Feb 2019  路  4Comments  路  Source: nodejs/node

This is a sub task of https://github.com/nodejs/node/issues/25908.

The whole repo means the src and test folder.

What I want is that let's take more time focus on code itself instead of chores like formatting.

Thought

cc @joyeecheung @addaleax @refack @bnoordhuis @jasnell @cjihrig

Most helpful comment

I agree with @richardlau , that was the reason I dropped https://github.com/nodejs/node/pull/16122 in favor of https://github.com/nodejs/node/pull/21997 which used the git-clang-format script to only format diffs instead of the whole repo. Unlike React or Babel we have a LTS support scheme and backport as much as possible, which makes this kind of formatting less feasible. (The git-clang-format approach was borrowed from electron under the advice from @codebytere)

Now if I have cpp format issue after I write the code. After clang-format the whole file, I have to revert the changes not related the change, that's quite a lot of work. I handle this a couple of times, not enjoy doing this at all tbh.

You can use git-clang-format for that, if you are on windows you can invoke the command manually (or add a shortcut similar to make format-cpp to vcbuild.bat). It could've been smarter if we had a convention to learn where the branch starts (like chromium's git cl format) but we do not have a complete toolchain to manage the life cycle of a PR branch yet.

All 4 comments

You can check current format change : gengjiawen@425befd

Showing 196 changed files with 14,443 additions and 15,533 deletions.

IMO that's way too much churn and will cause issues with backports and blaming.

IMO that's way too much churn and will cause issues with backports and blaming.

Actually prettier or eslint whole repo is common thing, we have git history for blaming part.
You can see other repo do the similar thing.

copyed from https://github.com/nodejs/node/issues/16115#issuecomment-439673388

I want to make cpp format easier in the long term.
Now if I have cpp format issue after I write the code. After clang-format the whole file, I have to revert the changes not related the change, that's quite a lot of work. I handle this a couple of times, not enjoy doing this at all tbh.

I agree with @richardlau , that was the reason I dropped https://github.com/nodejs/node/pull/16122 in favor of https://github.com/nodejs/node/pull/21997 which used the git-clang-format script to only format diffs instead of the whole repo. Unlike React or Babel we have a LTS support scheme and backport as much as possible, which makes this kind of formatting less feasible. (The git-clang-format approach was borrowed from electron under the advice from @codebytere)

Now if I have cpp format issue after I write the code. After clang-format the whole file, I have to revert the changes not related the change, that's quite a lot of work. I handle this a couple of times, not enjoy doing this at all tbh.

You can use git-clang-format for that, if you are on windows you can invoke the command manually (or add a shortcut similar to make format-cpp to vcbuild.bat). It could've been smarter if we had a convention to learn where the branch starts (like chromium's git cl format) but we do not have a complete toolchain to manage the life cycle of a PR branch yet.

@joyeecheung Thanks for the info.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Icemic picture Icemic  路  3Comments

dfahlander picture dfahlander  路  3Comments

stevenvachon picture stevenvachon  路  3Comments

willnwhite picture willnwhite  路  3Comments

akdor1154 picture akdor1154  路  3Comments