#!/usr/bin/env sh

# Support bash to support `source` with fallback on $0 if this does not run with bash
# https://stackoverflow.com/a/35006505/6512
selfArg="$BASH_SOURCE"
if [ -z "$selfArg" ]; then
    selfArg="$0"
fi

self=$(realpath $selfArg 2> /dev/null)
if [ -z "$self" ]; then
    self="$selfArg"
fi

dir=$(cd "${self%[/\\]*}" > /dev/null; cd '../scripts' && pwd)

PATH="$PATH:$dir"

usage() {
  echo -n "${scriptName} [OPTION]... [FILE]...

Returns true if local working copy is behind the git remote.
"
}

BRANCH_OR_TAG=`git-ref-type`
if  [ "$BRANCH_OR_TAG" != "branch" ]; then
  echo "Not on a branch."
  exit 1
fi

git fetch
BEHIND=$(git rev-list HEAD..FETCH_HEAD --count)

if  [ "$BEHIND" -gt "0" ]; then
  exit 0
else
  exit 1
fi
