Commit Graph

4 Commits (9011600b1ef5f60c9248553920b8d1a2b15b2fe7)

Author SHA1 Message Date
Eric Paris b7365ccace Check if people copy, but do not update the boilerplate
We found in that someone just copied/pasted the boilerplate language into
their code. But the boilerplate contains 2014, not 2015. We have 2 ways
to fix this.

1) Update the boilerplate to 2015 so people would get the right one.
2) Update the boilerplate so it doesn't make sense and then warn when
people use it.

This PR takes the second option. While options #1 seems easier, it will
get wrong in 2016, 17, 18 and it's unlikely anyone remember why they
need to update the boilerplate text and the regex rewrite. So just
make the humans do a tiny bit more work now.
2015-05-12 21:26:44 -04:00
Eric Paris 71d54198ed Spelll extension gooder 2015-05-08 19:19:33 -04:00
Eric Paris b503214fee Fix boilerplate check crash if .go file has no comments
Clayton pointed out that if he created a file with no /* in it anywhere
the boilerplate logic would crash like:

$ hack/verify-boilerplate.sh
Traceback (most recent call last):
  File "hack/../hooks/boilerplate.py", line 87, in <module>
    sys.exit(main())
  File "hack/../hooks/boilerplate.py", line 83, in main
    if not file_passes(filename, extention, ref, p):
  File "hack/../hooks/boilerplate.py", line 38, in file_passes
    while data[0] != "/*\n":
IndexError: list index out of range

That is because we were just stripping everything before the first line
that contained exacly "/*".  If no such line existed it got to the end
and just kept going.

This does something smarter. We use a regex to look for one or more
lines which start // +build followed by a single newline and remove only
those.  This obviously found one place where the package name was above
the license and was being missed by both the old and the new checker.

It also fixed the python spew and just tells you your file fails.
2015-05-08 17:30:40 -04:00
Eric Paris f4d0b8df3a Do all boilerplate checks in 1 python call
It's just a little bit faster.....

BEFORE:
$ time hack/verify-boilerplate.sh

real	0m9.378s
user	0m3.405s
sys	0m13.906s

AFTER:
$ time hack/verify-boilerplate.sh

real	0m0.181s
user	0m0.114s
sys	0m0.068s
2015-05-01 20:46:57 -04:00