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

Commit 33cddec

Browse files
committed
hack/validate-vendor.bash: fix build dep & script without TRAVIS_BRANCH
Signed-off-by: Jess Frazelle <[email protected]>
1 parent b839831 commit 33cddec

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

hack/validate-vendor.bash

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Copyright 2017 The Go Authors. All rights reserved.
33
# Use of this source code is governed by a BSD-style
44
# license that can be found in the LICENSE file.
@@ -8,25 +8,31 @@
88

99
set -e -o pipefail
1010

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

15+
VALIDATE_HEAD="$(git rev-parse --verify HEAD)"
16+
1717
git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH"
18-
TRAVIS_BRANCH="$(git rev-parse --verify FETCH_HEAD)"
19-
fi
18+
VALIDATE_UPSTREAM="$(git rev-parse --verify FETCH_HEAD)"
2019

21-
VALIDATE_HEAD="$(git rev-parse --verify HEAD)"
20+
VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"
21+
22+
validate_diff() {
23+
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
24+
git diff "$VALIDATE_COMMIT_DIFF" "$@"
25+
fi
26+
}
27+
fi
2228

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

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

0 commit comments

Comments
 (0)