Also maybe look at editorconfig [https://editorconfig.org/]
This can also help to have the same editor config across different
platforms and editors.

On Sun, May 23, 2021 at 2:25 PM YunKun Huang <[email protected]> wrote:
>
> This is an issue which needs to be fixed as soon as possible. but it
> always requires a good time to do it. because after format code, most
> of PR needs rework.
>
> I suggest doing it for the 3.0 version, there are not so many PR
> against 3.0 branches. Once all related PR is merged, we can do
> formatting first.
>
> On Sat, May 22, 2021 at 4:35 PM Albumen Kevin <[email protected]> wrote:
> >
> > Hi community,
> >
> > In apache/dubbo, there are a great amount of source files using CR LF
> > newline format due to Windows System.
> >
> > If contributors change these files, the git and IDE will
> > automatically reformat the files to LF newline format as default.
> >
> > It is possible for users to prevent this. That is setting `git config
> > --global core.autocrlf false`[1], but this will cause
> > IDE to warn users to remove this setting[2]. I have tried to create a
> > patch[3] for this, but it just works for new contributors,
> > who clone the repo after this pr.
> >
> > Git best practices recommend that all the files in repo are using LF
> > newline format and not only Git client in Windows but
> > Intellij IDEA has already made this action default for many years.
> >
> > There is a solution that is reformatting all source files at once and
> > adding a restricted code format checker to prevent users
> > from submitting CR LF newline format files. But this will cause that we
> > cannot easily track the source file's history previous
> > version by git blame[4]. In the file's history, there will be a node that
> > changes all lines, but we can still find the real previous
> > version by finding the reformatting commit's parent, which is the real
> > version of the history. The reformatting commit will be
> > a little like the pr[5][6] in dubbo-samples when removing golang samples.
> >
> > What do you think about this? Shall we make such a change to make all
> > source files more cleaner.
> >
> > [1] https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
> > [2]
> > https://blog.jetbrains.com/idea/2012/10/better-line-endings-managing-in-intellij-idea-12/
> > [3] https://github.com/apache/dubbo/pull/7229
> > [4] https://git-scm.com/docs/git-blame
> > [5]
> > https://github.com/apache/dubbo-samples/commit/19f02c2dc8a95cf18de33077bd1967ab048f462f
> > [6]
> > https://github.com/apache/dubbo-samples/commits/19f02c2dc8a95cf18de33077bd1967ab048f462f/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/api/GreetingService.java
> >
> > Thanks,
> > Albumen Kevin

Reply via email to