Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #369 from jessfraz/fix-vendor
Browse files Browse the repository at this point in the history
hack/validate-vendor.bash: fix build dep & script without TRAVIS_BRANCH
  • Loading branch information
sdboyer committed Apr 16, 2017
2 parents fe88577 + 7a4e405 commit 4610b1a
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions hack/validate-vendor.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
# Copyright 2017 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
Expand All @@ -8,25 +8,31 @@

set -e -o pipefail

# TRAVIS_BRANCH is the name of the branch targeted by the pull request.
# but we won't have that set if running locally
if [ -z "$TRAVIS_BRANCH" ]; then
VALIDATE_REPO='git@github.com:golang/dep.git'
if [ -z "$VALIDATE_UPSTREAM" ]; then
VALIDATE_REPO='https://github.com/golang/dep.git'
VALIDATE_BRANCH='master'

VALIDATE_HEAD="$(git rev-parse --verify HEAD)"

git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH"
TRAVIS_BRANCH="$(git rev-parse --verify FETCH_HEAD)"
fi
VALIDATE_UPSTREAM="$(git rev-parse --verify FETCH_HEAD)"

VALIDATE_HEAD="$(git rev-parse --verify HEAD)"
VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"

validate_diff() {
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
git diff "$VALIDATE_COMMIT_DIFF" "$@"
fi
}
fi

IFS=$'\n'
files=( $(git diff "$TRAVIS_BRANCH...$VALIDATE_HEAD" --diff-filter=ACMR --name-only -- 'Gopkg.toml' 'Gopkg.lock' 'vendor/' || true) )
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'Gopkg.toml' 'Gopkg.lock' 'vendor/' || true) )
unset IFS

if [ ${#files[@]} -gt 0 ]; then
# We run ensure to and see if we have a diff afterwards
go build
go build ./cmd/dep
./dep ensure
# Let see if the working directory is clean
diffs="$(git status --porcelain -- vendor Gopkg.toml Gopkg.lock 2>/dev/null)"
Expand Down

0 comments on commit 4610b1a

Please sign in to comment.