"Andrs, David" <[email protected]> writes: >> If you put this little "script" into .git/hooks/pre-commit, it will do it: >> > > Sorry, too fast. Here is the script: > > branch_name=$(git symbolic-ref -q HEAD) > if [ "$branch_name" == "refs/heads/maint" ] || [ "$branch_name" == > "refs/heads/next" ] > then > echo "Trying to commit to into " $branch_name ". This is normally not > desireable." > exit 1 > fi > > exit 0
Good call. The error message can provide instructions for moving the changes into a branch. > Not quite sure how to prevent that branching off of next. Just refuse non-merge commits if "git log HEAD..next" is empty, and give instructions to $ git stash $ git checkout -b user/new-feature master $ git stash pop Presumably merge commits can be identified by the presence of MERGE_HEAD. > The rest of the checks can probably go into pre-commit hook as well. > > The only problem is that it is a client side script, so it will not get > cloned from the central repo (AFAIK). My inclination would be to put it in an orphan branch within the repository and have a bin/maint/update-petsc-hooks that installs/updates the hooks. That way we can maintain the hooks without putting them in a totally separate repository. The hooks themselves could check the 'origin/hooks' branch to check whether it is out of date. Since a normal "git fetch" updates all branches, we'll know about updates without having to ping a remote server.
pgpJ4OH0dOMNi.pgp
Description: PGP signature
