Skip to content

Commit 3041b8a

Browse files
authored
Merge pull request kubernetes-csi#3 from pohly/verify-subtree
check subtree for changes
2 parents 520a04a + f28c6b6 commit 3041b8a

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

build.make

+21
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,32 @@ clean:
8989
-rm -rf bin
9090

9191
test:
92+
93+
.PHONY: test-go
94+
test: test-go
95+
test-go:
96+
@ echo; echo $@
9297
go test `go list ./... | grep -v 'vendor'` $(TESTARGS)
98+
99+
.PHONY: test-vet
100+
test: test-vet
101+
test-vet:
102+
@ echo; echo $@
93103
go vet `go list ./... | grep -v vendor`
104+
105+
.PHONY: test-fmt
106+
test: test-fmt
107+
test-fmt:
108+
@ echo; echo $@
94109
files=$$(find . -name '*.go' | grep -v './vendor'); \
95110
if [ $$(gofmt -d $$files | wc -l) -ne 0 ]; then \
96111
echo "formatting errors:"; \
97112
gofmt -d $$files; \
98113
false; \
99114
fi
115+
116+
.PHONY: test-subtree
117+
test: test-subtree
118+
test-subtree:
119+
@ echo; echo $@
120+
./release-tools/verify-subtree.sh release-tools

travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ matrix:
66
include:
77
- go: 1.11.1
88
script:
9-
- make all test
9+
- make -k all test
1010
after_success:
1111
- if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
1212
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" quay.io;

verify-subtree.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#! /bin/sh -e
2+
#
3+
# Copyright 2019 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# This script verifies that the content of a directory managed
18+
# by "git subtree" has not been modified locally. It does that
19+
# by looking for commits that modify the files with the
20+
# subtree prefix (aka directory) while ignoring merge
21+
# commits. Merge commits are where "git subtree" pulls the
22+
# upstream files into the directory.
23+
#
24+
# Theoretically a developer can subvert this check by modifying files
25+
# in a merge commit, but in practice that shouldn't happen.
26+
27+
DIR="$1"
28+
if [ ! "$DIR" ]; then
29+
echo "usage: $0 <directory>" >&2
30+
exit 1
31+
fi
32+
33+
REV=$(git log -n1 --format=format:%H --no-merges -- "$DIR")
34+
if [ "$REV" ]; then
35+
echo "Directory '$DIR' contains non-upstream changes:"
36+
echo
37+
git log --no-merges -- "$DIR"
38+
exit 1
39+
else
40+
echo "$DIR is a clean copy of upstream."
41+
fi

0 commit comments

Comments
 (0)