summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/git/README8
-rw-r--r--tools/git/git-utils.sh17
-rwxr-xr-xtools/git/post-checkout22
-rwxr-xr-xtools/git/post-merge12
4 files changed, 59 insertions, 0 deletions
diff --git a/tools/git/README b/tools/git/README
new file mode 100644
index 0000000..18d6da7
--- /dev/null
+++ b/tools/git/README
@@ -0,0 +1,8 @@
+This directory contains some helpful Git hooks.
+
+Currently, they warn you about DEPS modifications so you will remember
+to run "gclient sync".
+
+To install these Git hooks, create symlinks like so:
+ ln -s $(pwd)/post-checkout $(git rev-parse --git-dir)/hooks
+ ln -s $(pwd)/post-merge $(git rev-parse --git-dir)/hooks
diff --git a/tools/git/git-utils.sh b/tools/git/git-utils.sh
new file mode 100644
index 0000000..d89dc5d
--- /dev/null
+++ b/tools/git/git-utils.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+TPUT=$(which tput)
+if test -x "$TPUT" && $TPUT setaf 1 >/dev/null ; then
+ RED="$($TPUT setaf 1)"
+ NORMAL="$($TPUT op)"
+else
+ RED=
+ NORMAL=
+fi
+
+warn() {
+ echo "${RED}WARNING:${NORMAL} $@"
+}
diff --git a/tools/git/post-checkout b/tools/git/post-checkout
new file mode 100755
index 0000000..452eb48
--- /dev/null
+++ b/tools/git/post-checkout
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+script=$(readlink $0)
+source $(dirname ${script:-$0})/git-utils.sh
+
+old_ref=$1 # Previous HEAD.
+new_ref=$2 # Current HEAD.
+branch_switch=$3 # Whether we switched branches.
+
+if [ $old_ref == $new_ref ]; then
+ if ! git diff-index --quiet HEAD $(git rev-parse --show-cdup)DEPS; then
+ warn "DEPS has local modifications; do you need to re-run gclient sync?"
+ fi
+else
+ if git diff-tree $old_ref $new_ref | grep -qs $'\tDEPS$'; then
+ warn "DEPS has changed; you probably need to re-run gclient sync."
+ fi
+fi
+
diff --git a/tools/git/post-merge b/tools/git/post-merge
new file mode 100755
index 0000000..8b774ce
--- /dev/null
+++ b/tools/git/post-merge
@@ -0,0 +1,12 @@
+#!/bin/bash
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+script=$(readlink $0)
+source $(dirname ${script:-$0})/git-utils.sh
+
+if git diff-tree ORIG_HEAD HEAD | grep -qs $'\tDEPS$'; then
+ warn "DEPS has changed; you probably need to re-run gclient sync."
+fi
+