diff options
author | szager@chromium.org <szager@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 22:13:42 +0000 |
---|---|---|
committer | szager@chromium.org <szager@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 22:13:42 +0000 |
commit | c00e0b33bc019318ba8edf3b1b7edc90efa29fb3 (patch) | |
tree | bd45d76aedf392f3220790b3d3cfd9e47acdff91 /build/git-hooks | |
parent | 56f6fc5dfa538829584efb0a2d3dcebd958f7947 (diff) | |
download | chromium_src-c00e0b33bc019318ba8edf3b1b7edc90efa29fb3.zip chromium_src-c00e0b33bc019318ba8edf3b1b7edc90efa29fb3.tar.gz chromium_src-c00e0b33bc019318ba8edf3b1b7edc90efa29fb3.tar.bz2 |
Add pre-commit hook to disallow submodule changes.
TBR=cmp@chromium.org,iannucci@chromium.org
BUG=
Review URL: https://codereview.chromium.org/12260019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/git-hooks')
-rw-r--r-- | build/git-hooks/pre-commit | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/build/git-hooks/pre-commit b/build/git-hooks/pre-commit new file mode 100644 index 0000000..3ea49c5 --- /dev/null +++ b/build/git-hooks/pre-commit @@ -0,0 +1,34 @@ +#!/bin/bash + +submods=$(git diff-index --cached --ignore-submodules=dirty HEAD | grep -e '^:160000' -e '^:...... 160000' | xargs) +if test "$submods"; then + echo "You are trying to commit changes to the following submodules:" 1>&2 + echo 1>&2 + echo $submods | cut -d ' ' -f 6 | sed 's/^/ /g' 1>&2 + cat <<EOF 1>&2 + +Submodule commits are not allowed. Please run: + + git status --ignore-submodules=dirty + +and/or: + + git diff-index --cached --ignore-submodules=dirty HEAD + +... to see what's in your index. + +If you're really and truly trying to roll the version of a submodule, you should +commit the new version to DEPS, instead. +EOF + exit 1 +fi + +if test "$(git diff-index --cached HEAD .gitmodules)"; then + cat <<EOF 1>&2 +You are trying to commit a change to .gitmodules. That is not allowed. +To make changes to submodule names/paths, edit DEPS. +EOF + exit 1 +fi + +exit 0 |