Are CRLF lines ok in a Rails project deployed on Linux?

后端 未结 2 1336
时光取名叫无心
时光取名叫无心 2021-01-03 16:20

I have a Git repository (originally CVS, then SVN, now Git) containing a Rails project that has been deployed on Linux for a while now. Everything seems to run fine.

<
相关标签:
2条回答
  • 2021-01-03 16:39

    A comment to davitenio's answer and Daniel Beardsley's comment; I believe you could use this little program as a wrapper around dos2unix:

    #!/bin/sh
    for f in $@; do
        if [ $(file -b -n -i -m /dev/null $f | grep -c "text") -gt 0 ]; then
            dos2unix $f
        fi
    done
    

    although there is probably still some corner case that will fail.

    0 讨论(0)
  • 2021-01-03 16:54

    If it is ok for you to rewrite your repository's history (see problems with rewriting history) you could use git filter-branch to convert CRLF to LF:

    git filter-branch --tree-filter 'find . -path './.git' -prune -o -type f -exec dos2unix \{} \;' HEAD
    

    Note that if you have binary files in your repository you will have to refine the find command to exclude them.

    0 讨论(0)
提交回复
热议问题