Changeset 1900


Ignore:
Timestamp:
Sep 10, 2012, 1:10:07 PM (7 years ago)
Author:
sam
Message:

build: do not check for CRLF on Windows, since most files would have been
converted by the Vcs. Also ignore Trac plugins.

File:
1 edited

Legend:

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

    r1891 r1900  
    4747fi
    4848
     49# Find out whether we need to care about CRLF
     50case "$(uname 2>/dev/null)" in
     51  MINGW*)
     52    check_crlf=false
     53    ;;
     54  *)
     55    check_crlf=true
     56    ;;
     57esac
     58
    4959# Find out what kind of Vcs directory this is
    5060if [ -f "$top_srcdir/.git/index" ]; then
     
    5969fi
    6070
    61 total_errors=0
    62 total_files=0
    63 total_crs=0
     71total_crlfs=0
    6472total_spaces=0
    6573total_tabs=0
     
    7381fi
    7482
     83total_files=0
     84for file in $FILES; do
     85    if [ -f "$file" ]; then
     86        total_files="$(($total_files + 1))"
     87    fi
     88done
     89
     90total_errors=0
    7591for file in $FILES; do
    7692    case "$file" in
    77       src/bullet/*|contrib/*|*/generated/*)
    78           : # These files aren't ours, don't fix
     93      # These files aren't ours, don't fix
     94      src/bullet/*|contrib/*|*/generated/*|web/plugins/*)
     95          :
    7996          ;;
     97      # Don't harass these people
    8098      people/peeweek/*|people/touky/*)
    81           : # Don't harass these people
     99          :
    82100          ;;
    83       *.c|*.cpp|*.h|*.l|*.y)
     101      # These files we know how to handle
     102      *.c|*.cpp|*.m|*.mm|*.h|*.hh|*.lolfx|*.l|*.y|*.sh|*.py)
    84103          clean=true
    85104
    86105          # Check for CR LF
    87           ncrs="$(od -tx1 "$file" | cut -b8- | tr ' ' '\n' | grep -c 0d || true)"
    88           total_crs="$(($total_crs + $ncrs))"
    89           if [ "$ncrs" -gt 0 ]; then
    90               clean=false
    91               if [ "$fix" = true ]; then
    92                   $d2u -q "$file"
    93                   info "$file has $ncrs CR characters"
    94               else
    95                   error "$file has $ncrs CR characters"
     106          if [ "$check_crlf" = true ]; then
     107              ncrlfs="$(od -tx1 "$file" | cut -b8- | tr ' ' '\n' | grep -c 0d || true)"
     108              total_crlfs="$(($total_crlfs + $ncrlfs))"
     109              if [ "$ncrlfs" -gt 0 ]; then
     110                  clean=false
     111                  if [ "$fix" = true ]; then
     112                      $d2u -q "$file"
     113                      info "$file has $ncrlfs CR characters"
     114                  else
     115                      error "$file has $ncrlfs CR characters"
     116                  fi
    96117              fi
    97118          fi
     
    123144          fi
    124145
    125           total_files="$(($total_files + 1))"
    126146          if [ "$clean" != true ]; then
    127147              total_errors="$(($total_errors + 1))"
     
    137157        svn commit --username lolbot --non-interactive -F - << EOF
    138158fixed $total_errors files out of $total_files:
    139  - fixed $total_crs CR characters
    140  - fixed $total_spaces trailing spaces
    141  - fixed $total_tabs tabs
     159 - removed $total_crlfs CR characters
     160 - removed $total_spaces trailing whitespaces
     161 - replaced $total_tabs tabs with spaces
    142162EOF
    143163    elif [ "$fix" = "true" ]; then
    144164        # OR: report in stdout
    145165        info "fixed $total_errors files out of $total_files:"
    146         if [ "$total_crs" -gt 0 ]; then
    147             info " - fixed $total_crs CR characters"
     166        if [ "$total_crlfs" -gt 0 ]; then
     167            info " - fixed $total_crlfs CR characters"
    148168        fi
    149169        if [ "$total_spaces" -gt 0 ]; then
     
    157177        info "re-run with -w to fix errors"
    158178    fi
     179else
     180    info "all $total_files source files appear to be OK, congratulations"
    159181fi
    160182
Note: See TracChangeset for help on using the changeset viewer.