From 4fe7cefcd135e9be5e5b63c1a6fef2d1be72b2d0 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sat, 25 Apr 2020 00:19:27 -0400 Subject: [PATCH 1/2] Add a formatting script for Travis CI --- .travis.yml | 18 ++++++++++++++++++ format.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .travis.yml create mode 100755 format.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7106fe5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +dist: bionic + +stages: + - build + +matrix: + include: + - name: Static checks (format.sh) + stage: build + os: linux + addons: + apt: + packages: + - dos2unix + - recode + +script: + - bash ./format.sh diff --git a/format.sh b/format.sh new file mode 100755 index 0000000..5d90393 --- /dev/null +++ b/format.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do + # Exclude some types of files. + if [[ $f == *"proj" ]]; then + continue + elif [[ $f == *"filters" ]]; then + continue + elif [[ $f == *"sln" ]]; then + continue + elif [[ $f == *"json" ]]; then + continue + elif [[ $f == *"min.js" ]]; then + continue + fi + # Ensures that files are UTF-8 formatted. + recode UTF-8 $f 2> /dev/null + # Ensures that files have LF line endings. + dos2unix $f 2> /dev/null + # Ensures that files do not contain a BOM. + sed -i '1s/^\xEF\xBB\xBF//' "$f" + # Ensures that files end with newline characters. + tail -c1 < "$f" | read -r _ || echo >> "$f"; +done + +git diff > patch.patch +FILESIZE=$(stat -c%s patch.patch) +MAXSIZE=5 + +# If no patch has been generated all is OK, clean up, and exit. +if (( FILESIZE < MAXSIZE )); then + printf "Files in this commit comply with the formatting rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 From 409d9a502efdddc02744f98bdd3a93a8c37eb3b3 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sat, 25 Apr 2020 00:21:48 -0400 Subject: [PATCH 2/2] Commit files changed by the formatting script --- contrib/previewers/lib/README.md | 2 +- contrib/single_file_transcoder/examples/testcard-rgba.basis.inc | 2 +- contrib/single_file_transcoder/examples/testcard.basis.inc | 2 +- webgl/transcoder/build/basis_loader.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/previewers/lib/README.md b/contrib/previewers/lib/README.md index 4b5a7b8..bbd2508 100644 --- a/contrib/previewers/lib/README.md +++ b/contrib/previewers/lib/README.md @@ -1,3 +1,3 @@ # Single File Basis Universal Transcoder -Header and implementation generated using the [single file transcoder](../../single_file_transcoder) post-process script. Unlike the examples in that subproject here the transcoder header was kept as a seperate file (using the `-k` option, see the [README](../../single_file_transcoder/README.md)). \ No newline at end of file +Header and implementation generated using the [single file transcoder](../../single_file_transcoder) post-process script. Unlike the examples in that subproject here the transcoder header was kept as a seperate file (using the `-k` option, see the [README](../../single_file_transcoder/README.md)). diff --git a/contrib/single_file_transcoder/examples/testcard-rgba.basis.inc b/contrib/single_file_transcoder/examples/testcard-rgba.basis.inc index 7529728..6b9df6e 100644 --- a/contrib/single_file_transcoder/examples/testcard-rgba.basis.inc +++ b/contrib/single_file_transcoder/examples/testcard-rgba.basis.inc @@ -1040,4 +1040,4 @@ 0x85, 0x35, 0xe1, 0x51, 0x6a, 0xa9, 0x19, 0x6b, 0x00, 0x9b, 0xcb, 0x5f, 0xfb, 0xd8, 0xf8, 0x56, 0xfc, 0x3f, 0xe1, 0xda, 0xfa, 0xff, 0xf6, 0xe3, 0x9c, 0x0e, 0x16, 0xff, 0x31, 0x76, 0x1f, 0x00, 0xf6, 0x64, 0x13, 0xb6, -0xda, 0x38, 0x76, 0xb1, 0x11, 0xb6, 0xda, 0x38 \ No newline at end of file +0xda, 0x38, 0x76, 0xb1, 0x11, 0xb6, 0xda, 0x38 diff --git a/contrib/single_file_transcoder/examples/testcard.basis.inc b/contrib/single_file_transcoder/examples/testcard.basis.inc index 68102c1..d343ab2 100644 --- a/contrib/single_file_transcoder/examples/testcard.basis.inc +++ b/contrib/single_file_transcoder/examples/testcard.basis.inc @@ -700,4 +700,4 @@ 0xbf, 0xc0, 0x2f, 0x73, 0x60, 0x9f, 0x73, 0xf4, 0x1f, 0x93, 0xf9, 0x0b, 0xf6, 0x8f, 0xdb, 0xfb, 0x12, 0x3e, 0x8a, 0x83, 0x00, 0xa7, 0x1b, 0x6f, 0x76, 0x40, 0x5c, 0xe7, 0x7f, 0x02, 0xb9, 0xf3, 0x85, 0x79, 0x6b, 0x0f, -0x79, 0x6b, 0x79 \ No newline at end of file +0x79, 0x6b, 0x79 diff --git a/webgl/transcoder/build/basis_loader.js b/webgl/transcoder/build/basis_loader.js index f5cd071..8cd4a0e 100644 --- a/webgl/transcoder/build/basis_loader.js +++ b/webgl/transcoder/build/basis_loader.js @@ -491,4 +491,4 @@ if (!IN_WORKER) { fail(id, `No url or buffer specified`); } }; -} \ No newline at end of file +}