[roll] Roll Global Integration
GitOrigin-RevId: 6a7bf906e572c66d24aa4fe2c0f41f60236bbbb6
Change-Id: I45dc8a146565f59572ebedd1a206a4473ebccc3c
diff --git a/README.md b/README.md
index 188e5a3..463b31e 100644
--- a/README.md
+++ b/README.md
@@ -30,4 +30,3 @@
[internal version]: https://goto.google.com/fuchsia-internal-integration
[Jiri]: https://fuchsia.googlesource.com/jiri#Bootstrapping
-
diff --git a/flower b/flower
index 6ad2588..5b3a3e9 100644
--- a/flower
+++ b/flower
@@ -8,7 +8,7 @@
<projects>
<project name="experiences"
path="src/experiences"
- githooks=""
+ githooks="integration/git-hooks"
remote="https://fuchsia.googlesource.com/experiences"
gerrithost="https://fuchsia-review.googlesource.com"
revision="4368a48922ddd26cc0d652f27f9f4770713196c3"/>
diff --git a/git-hooks/commit-msg b/git-hooks/commit-msg
new file mode 100644
index 0000000..018a6ba
--- /dev/null
+++ b/git-hooks/commit-msg
@@ -0,0 +1,63 @@
+#!/bin/sh
+# From Gerrit Code Review 3.0.1-2625-g4f06d74558
+#
+# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
+#
+# Copyright (C) 2009 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# avoid [[ which is not POSIX sh.
+if test "$#" != 1 ; then
+ echo "$0 requires an argument."
+ exit 1
+fi
+
+if test ! -f "$1" ; then
+ echo "file does not exist: $1"
+ exit 1
+fi
+
+# Do not create a change id if requested
+if test "false" = "`git config --bool --get gerrit.createChangeId`" ; then
+ exit 0
+fi
+
+# $RANDOM will be undefined if not using bash, so don't use set -u
+random=$( (whoami ; hostname ; date; cat $1 ; echo $RANDOM) | git hash-object --stdin)
+dest="$1.tmp.${random}"
+
+trap 'rm -f "${dest}"' EXIT
+
+if ! git stripspace --strip-comments < "$1" > "${dest}" ; then
+ echo "cannot strip comments from $1"
+ exit 1
+fi
+
+if test ! -s "${dest}" ; then
+ echo "file is empty: $1"
+ exit 1
+fi
+
+# Avoid the --in-place option which only appeared in Git 2.8
+# Avoid the --if-exists option which only appeared in Git 2.15
+if ! git -c trailer.ifexists=doNothing interpret-trailers \
+ --trailer "Change-Id: I${random}" < "$1" > "${dest}" ; then
+ echo "cannot insert change-id line in $1"
+ exit 1
+fi
+
+if ! mv "${dest}" "$1" ; then
+ echo "cannot mv ${dest} to $1"
+ exit 1
+fi
diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit
new file mode 100644
index 0000000..4dfbdef
--- /dev/null
+++ b/git-hooks/pre-commit
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Check for Googlers not configuring their email address.
+# There are many examples of this in the git logs.
+AUTHORINFO=$(git var GIT_AUTHOR_IDENT) || exit 1
+EMAIL=$(echo "${AUTHORINFO}" | sed -n 's/^.* <\(.*\)> .*$/\1/p')
+
+if [[ "${EMAIL}" == *".corp.google.com" ]]; then
+ echo "Git is inferring your email to be ${EMAIL}. Please run:"
+ echo " git config --global user.email ${USER}@google.com"
+ exit 1
+fi
diff --git a/minimal b/minimal
index 477bca0..9740edd 100644
--- a/minimal
+++ b/minimal
@@ -4,7 +4,7 @@
<project name="integration"
path="integration"
remote="https://fuchsia.googlesource.com/integration"
- githooks=""
+ githooks="integration/git-hooks"
gerrithost="https://fuchsia-review.googlesource.com"/>
</projects>
</manifest>
diff --git a/stem b/stem
index b9de504..2edaaae 100644
--- a/stem
+++ b/stem
@@ -7,7 +7,7 @@
<projects>
<project name="fuchsia"
path="."
- githooks=""
+ githooks="integration/git-hooks"
remote="https://fuchsia.googlesource.com/fuchsia"
gerrithost="https://fuchsia-review.googlesource.com"
revision="ba5113442400b64d9d1538ee3ec0c0e700e7022d"/>