blob: 64719cbaad3b36f706f00dcbe2b67fb780767e60 [file] [log] [blame]
William Kurkianad745652019-03-20 08:45:51 -04001set -e
2
3#This test validates that go proto outputs are committed to git.
4#It does this by generating them and validating whether go thinks they are the same.
5#If they become out of sync, there can be problems for consumers of the protos.
6
7# Copyright 2018 the original author or authors.
8#
9# Licensed under the Apache License, Version 2.0 (the "License");
10# you may not use this file except in compliance with the License.
11# You may obtain a copy of the License at
12#
13# http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing, software
16# distributed under the License is distributed on an "AS IS" BASIS,
17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18# See the License for the specific language governing permissions and
19# limitations under the License.
20git status > /dev/null
21STAGED="$(git diff-index --quiet HEAD -- || echo 'staged')"
22UNTRACKED="$(git ls-files --exclude-standard --others)"
23
24if [ "$STAGED" == "staged" ] || [ "$UNTRACKED" != "" ]; then
25 echo "Please commit or ignore local changes before executing this test"
26 exit 1
27fi
28
29make go-protos
30
31# Running git status ensures correct git diff-index picks up changes
32git status > /dev/null
33
34STAGED_POST="$(git diff-index --quiet HEAD -- || echo "staged")"
35UNTRACKED_POST="$(git ls-files --exclude-standard --others)"
36
37if [ "$STAGED_POST" == "staged" ] || [ "$UNTRACKED_POST" != "" ] ; then
38 echo "You have go proto build outputs that are not committed."
39 echo "Check git status and commit updated files."
40 exit 1
41else
42 echo "Test successful. All go proto build outputs are committed"
43 exit 0
44fi
45