Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
- uses: actions/checkout@v2
- name: shellcheck
id: shellcheck
uses: ludeeus/actions-shellcheck@0.1.0
uses: project-chip/action-shellcheck@master
env:
EXCLUDE_DIRS: third_party
9 changes: 5 additions & 4 deletions integrations/clang/clang-format-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
# replacements.
#

# shellcheck disable=SC2120
die() {
echo " *** ERROR: " $*
echo " *** ERROR: $*"
exit 1
}

# from `man diff`:
# Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.

$(dirname "$0")/clang-format.sh -style=file $@ | diff -u $@ - || die
"$(dirname "$0")"/clang-format.sh -style=file "$@" | diff -u "$@" - || die "diffs exist"

for arg; do true; done
file=$arg
[ -n "$(tail -c1 $file)" ] && {
echo " *** ERROR: Missing EOF newline: " $file
[[ -n "$(tail -c1 "$file")" ]] && {
echo " *** ERROR: Missing EOF newline: $file"
exit 1
}

Expand Down
13 changes: 7 additions & 6 deletions integrations/clang/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

CLANG_FORMAT_VERSION="clang-format version 9.0"

# shellcheck disable=SC2120
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, at this point.

die() {
echo " *** ERROR: " $*
echo " *** ERROR: $*"
exit 1
}

if which clang-format-6.0 > /dev/null; then
if command -v clang-format-6.0 > /dev/null; then
alias clang-format=clang-format-9.0
elif which clang-format > /dev/null; then
elif command -v clang-format > /dev/null; then
case "$(clang-format --version)" in
"$CLANG_FORMAT_VERSION"*)
;;
Expand All @@ -21,7 +22,7 @@ else
die "clang-format 9.0 required"
fi

clang-format $@ || die
clang-format "$@" || die "format failed"

# ensure EOF newline
REPLACE=no
Expand All @@ -36,8 +37,8 @@ done

file=$arg

[ $REPLACE != yes ] || {
[ -n "$(tail -c1 $file)" ] && echo >> $file
[[ $REPLACE != yes ]] || {
[[ -n "$(tail -c1 "$file")" ]] && echo >> "$file"
}

exit 0