@@ -44,10 +44,6 @@ cd "${KUBE_ROOT}"
44
44
45
45
GENERATED_MOCK_FILE_REGEX=" ^// Code generated by mockery v[0-9.]\+. DO NOT EDIT.$"
46
46
47
- # pick a tempfile path for writing to
48
- tmp=$( mktemp)
49
- kube::util::trap_add " rm -f ${tmp:? } " EXIT
50
-
51
47
git_grep -l -z " ${GENERATED_MOCK_FILE_REGEX} " | xargs -0 rm -f
52
48
53
49
echo ' executing go generate command on below files'
@@ -73,58 +69,3 @@ git_grep -l -z "//go:generate mockery" | while read -r -d $'\0' file; do
73
69
go -C " $( dirname " $file " ) " generate " $( basename " $file " ) "
74
70
fi
75
71
done
76
-
77
- # get the changed or new mock files
78
- git ls-files -mo --exclude-standard -z | while read -r -d $' \0' file; do
79
- # only process files that appear to be mocks
80
- test -f " $file " || continue
81
- grep -q " ${GENERATED_MOCK_FILE_REGEX} " " $file " || continue
82
-
83
- # search for build tags used in file
84
- # //go:build !providerless
85
- # // +build !providerless
86
- go_build_tag_string=$( grep -o ' go:build.*$' " $file " ) || true
87
- build_tag_string=$( grep -o ' +build.*$' " $file " ) || true
88
- new_header=' '
89
-
90
- # if the file has both headers
91
- if [ -n " $build_tag_string " ] && [ -n " $go_build_tag_string " ]
92
- then
93
- # create a new header with the build string and the copyright text
94
- new_header=$( echo -e " //" " $go_build_tag_string " " \n" " //" " $build_tag_string " " \n" | cat - hack/boilerplate/boilerplate.generatego.txt)
95
-
96
- # ignore the first line (build tag) from the file
97
- tail -n +3 " $file " > " ${tmp} "
98
- fi
99
-
100
- # if the file has only // +build !providerless header
101
- if [ -n " $build_tag_string " ] && [ -z " $go_build_tag_string " ]
102
- then
103
- # create a new header with the build string and the copyright text
104
- new_header=$( echo -e " //" " $build_tag_string " " \n" | cat - hack/boilerplate/boilerplate.generatego.txt)
105
-
106
- # ignore the first line (build tag) from the file
107
- tail -n +2 " $file " > " ${tmp} "
108
- fi
109
-
110
- # if the file has only //go:build !providerless header
111
- if [ -z " $build_tag_string " ] && [ -n " $go_build_tag_string " ]
112
- then
113
- # create a new header with the build string and the copyright text
114
- new_header=$( echo -e " //" " $go_build_tag_string " " \n" | cat - hack/boilerplate/boilerplate.generatego.txt)
115
-
116
- # ignore the first line (build tag) from the file
117
- tail -n +2 " $file " > " ${tmp} "
118
- fi
119
-
120
- # if the header is generated
121
- if [ -n " $new_header " ]
122
- then
123
- # write the newly generated header file to the original file
124
- echo -e " $new_header " | cat - " ${tmp} " > " $file "
125
- else
126
- # if no build string insert at the top
127
- cat hack/boilerplate/boilerplate.generatego.txt " $file " > " ${tmp} " && \
128
- mv " ${tmp} " " $file "
129
- fi
130
- done
0 commit comments