github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/scripts/pre-push.bash (about)

     1  #!/bin/bash
     2  # Copyright 2013 Canonical Ltd.
     3  # Licensed under the AGPLv3, see LICENCE file for details.
     4  
     5  set -e
     6  
     7  z40=0000000000000000000000000000000000000000
     8  
     9  IFS=' '
    10  while read local_ref local_sha remote_ref remote_sha
    11  do
    12      if [ "$local_sha" = $z40 ]; then
    13          # delete remote branch, no check
    14          exit 0
    15      else
    16          git diff --quiet || (echo "unstaged changes"; exit 1)
    17          git diff --cached --quiet || (echo "uncommitted changes"; exit 1)
    18  
    19          if [ "$remote_sha" = $z40 ]
    20          then
    21              # New branch, examine all commits not on master
    22              range="$local_sha...master"
    23          else
    24              # Update to existing branch, examine new commits
    25              range="$remote_sha...$local_sha"
    26          fi
    27  
    28          FILECOUNT=`git log --name-only '--pretty=format:' $range | grep '.go$' | wc -l`
    29          if [ $FILECOUNT -eq 0 ]; then
    30              # no go files changed, skip go validation
    31              exit 0
    32          fi
    33  
    34          ./scripts/verify.bash
    35  
    36      fi
    37  done
    38