Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(969)

Unified Diff: build/git-hooks/pre-commit

Issue 12260019: Add pre-commit hook to disallow submodule changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/git-hooks/pre-commit
diff --git a/build/git-hooks/pre-commit b/build/git-hooks/pre-commit
new file mode 100644
index 0000000000000000000000000000000000000000..3ea49c572175c07a318f0c01d12a5cc7cbbe0abf
--- /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:
iannucci 2013/02/28 01:48:17 It might be nice to revise this to indicate that t
+
+ 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698