github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/scripts/pre-push.bash (about)

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