Merge pull request #136 from aaronfranke/travis

Add a formatting script for Travis CI
This commit is contained in:
Rich Geldreich
2020-05-06 19:57:43 -04:00
committed by GitHub
6 changed files with 67 additions and 4 deletions
+18
View File
@@ -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
+1 -1
View File
@@ -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)).
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)).
@@ -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
0xda, 0x38, 0x76, 0xb1, 0x11, 0xb6, 0xda, 0x38
@@ -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
0x79, 0x6b, 0x79
Executable
+45
View File
@@ -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 <hash>'\n"
rm -f patch.patch
exit 1
+1 -1
View File
@@ -491,4 +491,4 @@ if (!IN_WORKER) {
fail(id, `No url or buffer specified`);
}
};
}
}