parent
56e2a9741f
commit
dc58e4a441
|
@ -1,4 +1,4 @@
|
||||||
name: Elvis Linter
|
name: Code style check
|
||||||
|
|
||||||
on: [pull_request]
|
on: [pull_request]
|
||||||
|
|
||||||
|
@ -12,5 +12,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
|
echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
|
||||||
git config --global credential.helper store
|
git config --global credential.helper store
|
||||||
- run: |
|
- name: Run elvis check
|
||||||
|
run: |
|
||||||
./scripts/elvis-check.sh $GITHUB_BASE_REF
|
./scripts/elvis-check.sh $GITHUB_BASE_REF
|
||||||
|
- name: Check line-break at EOF
|
||||||
|
- run: |
|
||||||
|
./scripts/check-nl-at-eof.sh
|
|
@ -6,7 +6,7 @@ cd -P -- "$(dirname -- "$0")/.."
|
||||||
|
|
||||||
nl_at_eof() {
|
nl_at_eof() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
if ! [ -f $file ]; then
|
if ! [ -f "$file" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
case "$file" in
|
case "$file" in
|
||||||
|
@ -17,10 +17,16 @@ nl_at_eof() {
|
||||||
local lastbyte
|
local lastbyte
|
||||||
lastbyte="$(tail -c 1 "$file" 2>&1)"
|
lastbyte="$(tail -c 1 "$file" 2>&1)"
|
||||||
if [ "$lastbyte" != '' ]; then
|
if [ "$lastbyte" != '' ]; then
|
||||||
echo $file
|
echo "$file"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n=0
|
||||||
while read -r file; do
|
while read -r file; do
|
||||||
nl_at_eof "$file"
|
if ! nl_at_eof "$file"; then
|
||||||
|
n=$(( n + 1 ))
|
||||||
|
fi
|
||||||
done < <(git ls-files)
|
done < <(git ls-files)
|
||||||
|
|
||||||
|
exit $n
|
||||||
|
|
Loading…
Reference in New Issue