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:
parent
5dd049eb82
commit
45fea83771
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user