You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by Albumen Kevin <al...@apache.org> on 2021/05/22 08:35:22 UTC

[DISCUSS] Reformat the newlines separator of all source files

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

Re: [DISCUSS] Reformat the newlines separator of all source files

Posted by YunKun Huang <ht...@gmail.com>.
Cool !


On Thu, Jun 10, 2021 at 11:06 PM Albumen Kevin <al...@apache.org> wrote:
>
> Hi all,
>
> I have created a patch[1][2] for Apache Dubbo 3.0 branch to reformat the
> newlines separator for all source files to Unix style.
> Also, end lines with LF checker is enabled defaultly in Github Actions.
> Please note that this[3] requires that all new files should end with the LF
> line separator.
>
> [1] https://github.com/apache/dubbo/pull/8019
> [2] https://github.com/apache/dubbo/pull/8027
> [3] https://checkstyle.sourceforge.io/config_misc.html#NewlineAtEndOfFile
>
> Thanks,
> Albumen Kevin
>
>
> On Mon, May 31, 2021 at 5:59 PM Ian Luo <ia...@gmail.com> wrote:
>
> > +1. Dubbo 3.0 is a chance to fix this particular issue completely.
> >
> > -Ian.
> >
> > On Sat, May 22, 2021 at 4:35 PM Albumen Kevin <al...@apache.org> 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
> > >
> >

Re: [DISCUSS] Reformat the newlines separator of all source files

Posted by Albumen Kevin <al...@apache.org>.
Hi all,

I have created a patch[1][2] for Apache Dubbo 3.0 branch to reformat the
newlines separator for all source files to Unix style.
Also, end lines with LF checker is enabled defaultly in Github Actions.
Please note that this[3] requires that all new files should end with the LF
line separator.

[1] https://github.com/apache/dubbo/pull/8019
[2] https://github.com/apache/dubbo/pull/8027
[3] https://checkstyle.sourceforge.io/config_misc.html#NewlineAtEndOfFile

Thanks,
Albumen Kevin


On Mon, May 31, 2021 at 5:59 PM Ian Luo <ia...@gmail.com> wrote:

> +1. Dubbo 3.0 is a chance to fix this particular issue completely.
>
> -Ian.
>
> On Sat, May 22, 2021 at 4:35 PM Albumen Kevin <al...@apache.org> 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
> >
>

Re: [DISCUSS] Reformat the newlines separator of all source files

Posted by Ian Luo <ia...@gmail.com>.
+1. Dubbo 3.0 is a chance to fix this particular issue completely.

-Ian.

On Sat, May 22, 2021 at 4:35 PM Albumen Kevin <al...@apache.org> 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
>

Re: [DISCUSS] Reformat the newlines separator of all source files

Posted by YunKun Huang <ht...@gmail.com>.
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 <ht...@gmail.com> 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 <al...@apache.org> 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

Re: [DISCUSS] Reformat the newlines separator of all source files

Posted by YunKun Huang <ht...@gmail.com>.
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 <al...@apache.org> 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