double_semicolon_test revision 6ad1f2da4055e2cfe9bf8c79b79e408dba171691
0N/A#!/bin/bash
1045N/A
0N/Aset -e -u -o pipefail
0N/A
0N/A# An AWK regex matching tracked file paths to be included for the search.
0N/A# Example: '.*\.po|README'
0N/APATH_INCLUDE_REGEX='.*\.c|.*\.h'
0N/A
0N/Aexport GIT_DIR="$ABS_TOP_SRCDIR/.git"
0N/Aexport GIT_WORK_TREE="$ABS_TOP_SRCDIR"
0N/A
0N/Aif [ ! -d "$GIT_DIR" ]; then
0N/A echo "Git repository is required for this test!" 1>&2
0N/A exit 77
0N/Afi
0N/A
0N/A{
0N/A # Look for lines with double semicolon at the end of line
0N/A # in all files tracked by Git
0N/A git grep -n -I ';\s*;$' -- "$(git rev-parse --show-toplevel)" ||
0N/A # Don't fail if no such lines were found anywhere
0N/A [[ $? == 1 ]]
0N/A} |
0N/A awk -- "
0N/A BEGIN {
0N/A found = 0
0N/A }
0N/A /^($PATH_INCLUDE_REGEX):/ {
0N/A if (!found) {
0N/A print \"Double semicolon found:\"
0N/A found = 1
0N/A }
0N/A print
0N/A }
0N/A END {
0N/A exit found
0N/A }
0N/A "
0N/A