github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/hack/validate/.validate (about)

     1  #!/usr/bin/env bash
     2  
     3  set -e -o pipefail
     4  
     5  if [ -z "$VALIDATE_UPSTREAM" ]; then
     6  	# this is kind of an expensive check, so let's not do this twice if we
     7  	# are running more than one validate bundlescript
     8  
     9  	VALIDATE_REPO="${VALIDATE_REPO:-https://github.com/demonoid81/moby.git}"
    10  	VALIDATE_BRANCH="${VALIDATE_BRANCH:-master}"
    11  
    12  	VALIDATE_HEAD="$(git rev-parse --verify HEAD)"
    13  
    14  	if [ -z "$VALIDATE_ORIGIN_BRANCH" ]; then
    15  		git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH"
    16  		VALIDATE_ORIGIN_BRANCH=FETCH_HEAD
    17  	fi
    18  	VALIDATE_UPSTREAM="$(git rev-parse --verify $VALIDATE_ORIGIN_BRANCH)"
    19  
    20  	VALIDATE_COMMIT_LOG="$VALIDATE_UPSTREAM..$VALIDATE_HEAD"
    21  	VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"
    22  
    23  	validate_diff() {
    24  		if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
    25  			git diff "$VALIDATE_COMMIT_DIFF" "$@"
    26  		fi
    27  	}
    28  	validate_log() {
    29  		if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
    30  			git log "$VALIDATE_COMMIT_LOG" "$@"
    31  		fi
    32  	}
    33  fi