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