Skip to content

Commit

Permalink
Update regex match in verify_boilerplate.py
Browse files Browse the repository at this point in the history
* In v0.14.0 controller-gen, we have headers like
```
//go:build !ignore_autogenerated

```
instead of
```
//go:build !ignore_autogenerated
// +build !ignore_autogenerated

```.

And this could result in error when running make verify-boilerplate
since it always expect to `//go:build !ignore_autogenerated` to not have
`\n` as next line, but followed by `// +build !ignore_autogenerated`
which contains a new line.
  • Loading branch information
sawsa307 committed Feb 7, 2024
1 parent 81e1fab commit cb1f8b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hack/verify/verify_boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def file_passes(filename, refs, regexs): # pylint: disable=too-many-locals
(data, found) = con.subn("", data, 1)
con = regexs["go_build_constraints_2"]
(data, found) = con.subn("", data, 1)

con = regexs["go_build_constraints_3"]
(data, found) = con.subn("", data, 1)

# remove shebang from the top of shell files
if extension in ("sh", "py"):
she = regexs["shebang"]
Expand Down Expand Up @@ -234,6 +236,8 @@ def get_regexs():
r"^(// \+build.*\n)+\n", re.MULTILINE)
# strip //go:build build constraints
regexs["go_build_constraints_2"] = re.compile(
r"^(//go:build.*\n)+\n", re.MULTILINE)
regexs["go_build_constraints_3"] = re.compile(
r"^(//go:build.*\n)", re.MULTILINE)
# strip #!.* from shell/python scripts
regexs["shebang"] = re.compile(r"^(#!.*\n)\n*", re.MULTILINE)
Expand Down

0 comments on commit cb1f8b0

Please sign in to comment.