1#!/bin/bash 2# 3# Copyright (c) 2015 Google Inc. 4# 5# This is a pre-push hook that does the following before uploading a 6# CL for review: 7# 1) check that python sources have been formatted with yapf. 8# 2) allows the user to run the unit tests. 9 10mydir="$(dirname "$(readlink -m "$0")")" 11 12z40=0000000000000000000000000000000000000000 13 14while IFS=' ' read local_ref local_sha remote_ref remote_sha; do 15 if [[ "$local_sha" != $z40 ]]; then 16 if [[ "$remote_sha" == $z40 ]]; then 17 # New branch, examine commit on top of branch. 18 range="$local_sha" 19 else 20 # Update to existing branch, examine new commits 21 range="$remote_sha..$local_sha" 22 fi 23 all_files="$(git show --pretty="format:" --name-only "${range}")" 24 # Note that ${all_files} may include files that were deleted. Hence, we 25 # ignore any complaints about missing files. 26 IGNORE_MISSING=1 "${mydir}/check-presubmit" ${all_files} || exit 1 27 fi 28done 29 30exit 0 31