Changeset 2739


Ignore:
Timestamp:
Jun 17, 2013, 2:24:00 PM (6 years ago)
Author:
sam
Message:

build: fix CRLF issues in user directories even if they're whitelisted, or git-svn
users will get all sorts of weird conflicts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/build/check-source.sh

    r2738 r2739  
    6363case "$(uname 2>/dev/null)" in
    6464  MINGW*)
    65     check_crlf=false
     65    can_check_crlf=false
    6666    ;;
    6767  *)
    68     check_crlf=true
     68    can_check_crlf=true
    6969    ;;
    7070esac
     
    104104total_errors=0
    105105for file in $FILES; do
     106    should_check_crlf=false
     107    should_check_spaces=false
    106108
    107109    case "$file" in
    108110      # These files we know how to handle
    109111      *.c|*.cpp|*.m|*.mm|*.h|*.hh|*.lolfx|*.lua|*.l|*.y|*.sh|*.py)
    110           fix_method="all"
     112          should_check_crlf=true
     113          should_check_spaces=true
    111114          ;;
    112115      *)
     
    132135      people/benlitz/*|\
    133136      people/sam/lua-*)
    134           fix_method="crlf"
     137          should_check_spaces=false
    135138          ;;
    136139    esac
     
    139142
    140143    # Check for CR LF
    141     if [ "$check_crlf" = true ]; then
     144    if [ "$can_check_crlf" = true -a "$should_check_crlf" = true ]; then
    142145        ncrlfs="$(od -tx1 "$file" | cut -b8- | tr ' ' '\n' | grep -c 0d || true)"
    143146        total_crlfs="$(($total_crlfs + $ncrlfs))"
     
    154157
    155158    # Check for trailing spaces
    156     nspaces="$($SED 's/.*[^ \t]//' "$file" | tr -cd '\t ' | wc -c)"
    157     total_spaces="$(($total_spaces + $nspaces))"
    158     if [ "$nspaces" -gt 0 -a "$fix_method" = "all" ]; then
    159         clean=false
    160         if [ "$fix" = true ]; then
    161             $SED -i 's/[[:space:]][[:space:]]*$//g' "$file"
    162             info "$file has $nspaces trailing spaces"
    163         else
    164             error "$file has $nspaces trailing spaces"
     159    if [ "$should_check_spaces" = true ]; then
     160        nspaces="$($SED 's/.*[^ \t]//' "$file" | tr -cd '\t ' | wc -c)"
     161        total_spaces="$(($total_spaces + $nspaces))"
     162        if [ "$nspaces" -gt 0 ]; then
     163            clean=false
     164            if [ "$fix" = true ]; then
     165                $SED -i 's/[[:space:]][[:space:]]*$//g' "$file"
     166                info "$file has $nspaces trailing spaces"
     167            else
     168                error "$file has $nspaces trailing spaces"
     169            fi
    165170        fi
    166171    fi
    167172
    168173    # Check for tabs
    169     ntabs="$(tr -cd '\t' < "$file" | wc -c)"
    170     total_tabs="$(($total_tabs + $ntabs))"
    171     if [ "$ntabs" -gt 0 -a "$fix_method" = "all" ]; then
    172         clean=false
    173         if [ "$fix" = true ]; then
    174             $SED -i 's/\t/    /g' "$file"
    175             info "$file has $ntabs tabs"
    176         else
    177             error "$file has $ntabs tabs"
     174    if [ "$should_check_spaces" = true ]; then
     175        ntabs="$(tr -cd '\t' < "$file" | wc -c)"
     176        total_tabs="$(($total_tabs + $ntabs))"
     177        if [ "$ntabs" -gt 0 ]; then
     178            clean=false
     179            if [ "$fix" = true ]; then
     180                $SED -i 's/\t/    /g' "$file"
     181                info "$file has $ntabs tabs"
     182            else
     183                error "$file has $ntabs tabs"
     184            fi
    178185        fi
    179186    fi
Note: See TracChangeset for help on using the changeset viewer.