diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-11-07 15:39:47 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-11-07 16:25:52 +0000 |
| commit | f9c0cd6946b545524891cbe6eaafb3bd773b9b0a (patch) | |
| tree | 239b2e7de862a584fb45307956966f0742bdf123 | |
| parent | 8f815ccc244597135fc5b9f74aeb0e5d96ce8eb5 (diff) | |
tools: add HTML checking script
Check that HTML files are not inconsistently formatted
with both tabs and spaces.
| -rw-r--r-- | Makefile | 7 | ||||
| -rwxr-xr-x | tools/check-html.sh | 20 |
2 files changed, 25 insertions, 2 deletions
@@ -105,7 +105,7 @@ endif extract generate generate_go generate_rpc generate_sys \ format format_go format_cpp format_sys \ tidy test test_race \ - check_copyright check_language check_whitespace check_links check_diff check_commits check_shebang \ + check_copyright check_language check_whitespace check_links check_diff check_commits check_shebang check_html \ presubmit presubmit_aux presubmit_build presubmit_arch_linux presubmit_arch_freebsd \ presubmit_arch_netbsd presubmit_arch_openbsd presubmit_arch_darwin presubmit_arch_windows \ presubmit_arch_executor presubmit_dashboard presubmit_race presubmit_race_dashboard presubmit_old @@ -307,7 +307,7 @@ presubmit: presubmit_aux: $(MAKE) generate - $(MAKE) -j100 check_commits check_diff check_copyright check_language check_whitespace check_links check_shebang tidy + $(MAKE) -j100 check_commits check_diff check_copyright check_language check_whitespace check_links check_html check_shebang tidy $(GO) mod tidy presubmit_build: descriptions @@ -428,6 +428,9 @@ check_commits: check_links: python ./tools/check_links.py $$(pwd) $$(find . -name '*.md' | grep -v "./vendor/") +check_html: + ./tools/check-html.sh + # Check that the diff is empty. This is meant to be executed after generating # and formatting the code to make sure that everything is committed. check_diff: diff --git a/tools/check-html.sh b/tools/check-html.sh new file mode 100755 index 000000000..1b122329e --- /dev/null +++ b/tools/check-html.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Copyright 2024 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +FILES=0 +FAILED="" +for F in $(find . -name "*.html"); do + ((FILES+=1)) + TABS=`cat $F | grep " " | wc -l` + # templates.html uses several spaces to format commit info using fixed-width font. + SPACES=`cat $F | grep -v "Commit.Date" | grep " " | wc -l` + if [ "$TABS" = "0" ] || [ "$SPACES" = "0" ]; then continue; fi + # Ignore untracked files. + git ls-files --error-unmatch $F >/dev/null 2>&1 + if [ $? -ne 0 ]; then continue; fi + echo "$F:1:1: Uses both spaces ($SPACES) and tabs ($TABS) for formatting. Use either one of these." + FAILED="1" +done +if [ "$FAILED" != "" ]; then exit 1; fi +echo "$FILES HTML files checked for formatting" |
