소스 검색

build: fix CRLF issues in user directories even if they're whitelisted, or git-svn

users will get all sorts of weird conflicts.
legacy
Sam Hocevar sam 11 년 전
부모
커밋
5131c96130
1개의 변경된 파일30개의 추가작업 그리고 23개의 파일을 삭제
  1. +30
    -23
      build/check-source.sh

+ 30
- 23
build/check-source.sh 파일 보기

@@ -62,10 +62,10 @@ fi
# Find out whether we need to care about CRLF
case "$(uname 2>/dev/null)" in
MINGW*)
check_crlf=false
can_check_crlf=false
;;
*)
check_crlf=true
can_check_crlf=true
;;
esac

@@ -103,11 +103,14 @@ done

total_errors=0
for file in $FILES; do
should_check_crlf=false
should_check_spaces=false

case "$file" in
# These files we know how to handle
*.c|*.cpp|*.m|*.mm|*.h|*.hh|*.lolfx|*.lua|*.l|*.y|*.sh|*.py)
fix_method="all"
should_check_crlf=true
should_check_spaces=true
;;
*)
continue
@@ -131,14 +134,14 @@ for file in $FILES; do
people/touky/*|\
people/benlitz/*|\
people/sam/lua-*)
fix_method="crlf"
should_check_spaces=false
;;
esac

clean=true

# Check for CR LF
if [ "$check_crlf" = true ]; then
if [ "$can_check_crlf" = true -a "$should_check_crlf" = true ]; then
ncrlfs="$(od -tx1 "$file" | cut -b8- | tr ' ' '\n' | grep -c 0d || true)"
total_crlfs="$(($total_crlfs + $ncrlfs))"
if [ "$ncrlfs" -gt 0 ]; then
@@ -153,28 +156,32 @@ for file in $FILES; do
fi

# Check for trailing spaces
nspaces="$($SED 's/.*[^ \t]//' "$file" | tr -cd '\t ' | wc -c)"
total_spaces="$(($total_spaces + $nspaces))"
if [ "$nspaces" -gt 0 -a "$fix_method" = "all" ]; then
clean=false
if [ "$fix" = true ]; then
$SED -i 's/[[:space:]][[:space:]]*$//g' "$file"
info "$file has $nspaces trailing spaces"
else
error "$file has $nspaces trailing spaces"
if [ "$should_check_spaces" = true ]; then
nspaces="$($SED 's/.*[^ \t]//' "$file" | tr -cd '\t ' | wc -c)"
total_spaces="$(($total_spaces + $nspaces))"
if [ "$nspaces" -gt 0 ]; then
clean=false
if [ "$fix" = true ]; then
$SED -i 's/[[:space:]][[:space:]]*$//g' "$file"
info "$file has $nspaces trailing spaces"
else
error "$file has $nspaces trailing spaces"
fi
fi
fi

# Check for tabs
ntabs="$(tr -cd '\t' < "$file" | wc -c)"
total_tabs="$(($total_tabs + $ntabs))"
if [ "$ntabs" -gt 0 -a "$fix_method" = "all" ]; then
clean=false
if [ "$fix" = true ]; then
$SED -i 's/\t/ /g' "$file"
info "$file has $ntabs tabs"
else
error "$file has $ntabs tabs"
if [ "$should_check_spaces" = true ]; then
ntabs="$(tr -cd '\t' < "$file" | wc -c)"
total_tabs="$(($total_tabs + $ntabs))"
if [ "$ntabs" -gt 0 ]; then
clean=false
if [ "$fix" = true ]; then
$SED -i 's/\t/ /g' "$file"
info "$file has $ntabs tabs"
else
error "$file has $ntabs tabs"
fi
fi
fi



불러오는 중...
취소
저장