Index: third_party/grpc/tools/distrib/check_trailing_newlines.sh |
diff --git a/third_party/WebKit/LayoutTests/http/tests/websocket/close_wsh.py b/third_party/grpc/tools/distrib/check_trailing_newlines.sh |
old mode 100644 |
new mode 100755 |
similarity index 57% |
copy from third_party/WebKit/LayoutTests/http/tests/websocket/close_wsh.py |
copy to third_party/grpc/tools/distrib/check_trailing_newlines.sh |
index 1b02d66267e294ce83977dac64f075981705647c..0be21f0cfffb0583928cb14c34888c7f526d2de5 |
--- a/third_party/WebKit/LayoutTests/http/tests/websocket/close_wsh.py |
+++ b/third_party/grpc/tools/distrib/check_trailing_newlines.sh |
@@ -1,4 +1,5 @@ |
-# Copyright 2011, Google Inc. |
+#!/bin/bash |
+# Copyright 2016, Google Inc. |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
@@ -27,27 +28,40 @@ |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+# change to root directory |
+cd $(dirname $0)/../.. |
-import logging |
-_GOODBYE_MESSAGE = u'Goodbye' |
+function find_without_newline() { |
+ find . -type f -not -path './third_party/*' -and \( \ |
+ -name '*.c' \ |
+ -or -name '*.cc' \ |
+ -or -name '*.proto' \ |
+ -or -name '*.rb' \ |
+ -or -name '*.py' \ |
+ -or -name '*.cs' \ |
+ -or -name '*.sh' \) -print0 \ |
+ | while IFS= read -r -d '' f; do |
+ if [[ ! -z $f ]]; then |
+ if [[ $(tail -c 1 "$f") != $NEWLINE ]]; then |
+ echo "Error: file '$f' is missing a trailing newline character." |
+ if $2; then # fix |
+ sed -i -e '$a\' $f |
+ echo 'Fixed!' |
+ fi |
+ fi |
+ fi |
+ done |
+} |
+if [[ $# == 1 && $1 == '--fix' ]]; then |
+ ERRORS=$(find_without_newline true) |
+else |
+ ERRORS=$(find_without_newline false) |
+fi |
-def web_socket_do_extra_handshake(request): |
- pass # Always accept. |
- |
- |
-def web_socket_transfer_data(request): |
- while True: |
- line = request.ws_stream.receive_message() |
- if line is None: |
- return |
- if isinstance(line, unicode): |
- request.ws_stream.send_message(line, binary=False) |
- if line == _GOODBYE_MESSAGE: |
- return |
- else: |
- request.ws_stream.send_message(line, binary=True) |
- |
- |
-def web_socket_passive_closing_handshake(request): |
- return request.ws_close_code, request.ws_close_reason |
+if [[ "$ERRORS" != '' ]]; then |
+ echo "$ERRORS" |
+ if ! $FIX; then |
+ exit 1 |
+ fi |
+fi |