#!/bin/sh # # An example hook script to verify what is about to be committed. # Called by "git commit" with no arguments. The hook should # exit with non-zero status after issuing an appropriate message if # it wants to stop the commit. # # To enable this hook, rename this file to "pre-commit". if git rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD else # Initial commit: diff against an empty tree object against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi branch=`git status -b| grep "# On branch"| cut -f4 -d\ ` if test "$branch" == "develop" then echo "$(tput setaf 1)ERROR: Committing directly to develop is not allowed while we still have an svn repo.$(tput sgr0)" exit 1 fi if test "$branch" == "master" then echo "$(tput setaf 1)ERROR: Committing directly to master is not allowed.$(tput sgr0)" exit 1 fi if test "$branch" \!= "develop" -a "$branch" \!= "master" -a "$branch" \!= "svn" then if test \! -e README.md then echo "$(tput setaf 1)ERROR: Branches that are not develop or master must have a README.md file describing them" echo "ERROR: current branch is" $branch "$(tput sgr0)" exit 1 fi fi # Redirect output to stderr. exec 1>&2 files=`git diff-index --name-only $against` if test -n "$files" then if python `git rev-parse --show-toplevel`/tools/check-standards.py `git diff-index --name-only $against` then echo "Format checks OK." else exit 1 fi fi untracked=`git status -u --porcelain | grep '^??'` if test -n "$untracked" then echo "$(tput setaf 1)ERROR: There are untracked files in your repository.$(tput sgr0)" echo "If you want to keep them around you can add them to your .git/info/exclude file: " `echo $untracked | cut -f2 -d\ ` echo "You can use --no-verify to skip checks if you are sure that is what you want." exit 1 fi