|
1 |
| -#!/bin/bash |
| 1 | +#!/usr/bin/env bash |
2 | 2 | # Copyright 2017 The Go Authors. All rights reserved.
|
3 | 3 | # Use of this source code is governed by a BSD-style
|
4 | 4 | # license that can be found in the LICENSE file.
|
|
8 | 8 |
|
9 | 9 | set -e -o pipefail
|
10 | 10 |
|
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' |
15 | 13 | VALIDATE_BRANCH='master'
|
16 | 14 |
|
| 15 | + VALIDATE_HEAD="$(git rev-parse --verify HEAD)" |
| 16 | + |
17 | 17 | 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)" |
20 | 19 |
|
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 |
22 | 28 |
|
23 | 29 | IFS=$'\n'
|
24 |
| -files=( $(git diff "$TRAVIS_BRANCH...$VALIDATE_HEAD" --diff-filter=ACMR --name-only -- 'manifest.json' 'lock.json' 'vendor/' || true) ) |
| 30 | +files=( $(validate_diff --diff-filter=ACMR --name-only -- 'Gopkg.toml' 'Gopkg.lock' 'vendor/' || true) ) |
25 | 31 | unset IFS
|
26 | 32 |
|
27 | 33 | if [ ${#files[@]} -gt 0 ]; then
|
28 | 34 | # We run ensure to and see if we have a diff afterwards
|
29 |
| - go build |
| 35 | + go install ./cmd/dep |
30 | 36 | ./dep ensure
|
31 | 37 | # Let see if the working directory is clean
|
32 |
| - diffs="$(git status --porcelain -- vendor manifest.json lock.json 2>/dev/null)" |
| 38 | + diffs="$(git status --porcelain -- vendor Gopkg.toml Gopkg.lock 2>/dev/null)" |
33 | 39 | if [ "$diffs" ]; then
|
34 | 40 | {
|
35 | 41 | echo 'The result of ensure differs'
|
|
0 commit comments