#!/bin/bash
preHookPath=`git config core.hooksPath`;
length=${#preHookPath};
if [ $length = 0 ]; then
  preHookPath=".git/hooks";
fi
preCommitFile="../${preHookPath}/pre-commit";
if [ ! -e "$preCommitFile" ]; then
	echo -en "#!/bin/sh \ncd ${PWD} && php bitrix/tools/console info" > $preCommitFile
else
	if ! grep -q "php bitrix/tools/console info" "$preCommitFile"; then
    echo -en "\ncd ${PWD} && php bitrix/tools/console info" >> $preCommitFile
  fi
fi
chmod a+x $preCommitFile;
