1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-24 08:52:21 +02:00

Convert \r\n to \n; don't depend on unix2dos

This commit is contained in:
Tommy Nguyen 2018-08-20 09:16:35 -04:00
parent 5dd049eb82
commit 45fea83771
No known key found for this signature in database
GPG Key ID: DB7FA8161647D196
3 changed files with 9 additions and 6 deletions

View File

@ -66,7 +66,7 @@ func TrimTrailingNewline(str string) string {
// NormalizeLinefeeds - Removes all Windows and Mac style line feeds
func NormalizeLinefeeds(str string) string {
str = strings.Replace(str, "\r\n", "", -1)
str = strings.Replace(str, "\r\n", "\n", -1)
str = strings.Replace(str, "\r", "", -1)
return str
}

View File

@ -91,7 +91,12 @@ func TestNormalizeLinefeeds(t *testing.T) {
{
// \r\n
[]byte{97, 115, 100, 102, 13, 10},
[]byte{97, 115, 100, 102},
[]byte{97, 115, 100, 102, 10},
},
{
// bash\r\nblah
[]byte{97, 115, 100, 102, 13, 10, 97, 115, 100, 102},
[]byte{97, 115, 100, 102, 10, 97, 115, 100, 102},
},
{
// \r

View File

@ -4,12 +4,10 @@ set -ex; rm -rf repo; mkdir repo; cd repo
git init
cat <<EOT >> windowslf.txt
asdf
asdf
asdf
asdf
EOT
unix2dos windowslf.txt
cat <<EOT >> linuxlf.txt
asdf
asdf