mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-03 00:57:52 +02:00
Convert \r\n to \n; don't depend on unix2dos
This commit is contained in:
@ -66,7 +66,7 @@ func TrimTrailingNewline(str string) string {
|
|||||||
|
|
||||||
// NormalizeLinefeeds - Removes all Windows and Mac style line feeds
|
// NormalizeLinefeeds - Removes all Windows and Mac style line feeds
|
||||||
func NormalizeLinefeeds(str string) string {
|
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)
|
str = strings.Replace(str, "\r", "", -1)
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,12 @@ func TestNormalizeLinefeeds(t *testing.T) {
|
|||||||
{
|
{
|
||||||
// \r\n
|
// \r\n
|
||||||
[]byte{97, 115, 100, 102, 13, 10},
|
[]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
|
// \r
|
||||||
|
@ -4,12 +4,10 @@ set -ex; rm -rf repo; mkdir repo; cd repo
|
|||||||
git init
|
git init
|
||||||
|
|
||||||
cat <<EOT >> windowslf.txt
|
cat <<EOT >> windowslf.txt
|
||||||
asdf
|
asdf
|
||||||
asdf
|
asdf
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
unix2dos windowslf.txt
|
|
||||||
|
|
||||||
cat <<EOT >> linuxlf.txt
|
cat <<EOT >> linuxlf.txt
|
||||||
asdf
|
asdf
|
||||||
asdf
|
asdf
|
||||||
|
Reference in New Issue
Block a user