Skip to content
Snippets Groups Projects
Select Git revision
  • ade9a6dd76a3b66a896ea171a64496e7693b3399
  • develop default
  • 2023.w43
  • 2023.w42
  • 2023.w41
  • 2023.w40
  • 2023.w39
  • 2023.w38
  • 2023.w37
  • 2023.w36
  • 2023.w34
  • 2023.w33
  • 2023.w32
  • v2.0.0
  • 2023.w31
  • 2023.w30
  • 2023.w29
  • 2023.w28
  • 2023.w27
  • 2023.w26
  • 2023.w25
  • 2023.w24
22 results

NOTICE.txt

Blame
  • pre-commit 851 B
    
    #!/bin/bash
    # Installation:
    #   cp pre-commit .git/hooks
    #   chmod +x .git/hooks/pre-commit
    
    OPTIONS="--convert-tabs --indent=spaces=2 --indent-switches --indent-col1-comments --break-blocks --delete-empty-lines --align-pointer=name --keep-one-line-blocks --keep-one-line-statements --lineend=linux"
    
    RETURN=0
    ASTYLE=$(which astyle)
    if [ $? -ne 0 ]; then
    	echo "[!] astyle not installed. Unable to check source file format policy." >&2
    	exit 1
    fi
    
    FILES=`git diff --cached --name-only --diff-filter=ACMR | grep -E "\.(c|cpp|h)$"`
    for FILE in $FILES; do
    	$ASTYLE $OPTIONS < $FILE | cmp -s $FILE -
    	if [ $? -ne 0 ]; then
    		echo "[!] $FILE does not respect the agreed coding style." >&2
    		RETURN=1
    	fi
    done
    
    if [ $RETURN -eq 1 ]; then
    	echo "" >&2
    	echo "Make sure you have run astyle with the following options:" >&2
    	echo $OPTIONS >&2
    fi
    
    exit $RETURN