diff --git a/hooks/boilerplate.py b/hooks/boilerplate.py index 72497f5840b..72fcf9709d6 100755 --- a/hooks/boilerplate.py +++ b/hooks/boilerplate.py @@ -33,11 +33,16 @@ def file_passes(filename, extension, ref, regexs): data = f.read() - # remove build tags from the top of Go file + # remove build tags from the top of Go files if extension == "go": p = regexs["go_build_constraints"] (data, found) = p.subn("", data, 1) + # remove shebang from the top of shell files + if extension == "sh": + p = regexs["shebang"] + (data, found) = p.subn("", data, 1) + data = data.splitlines() # if our test file is smaller than the reference it surely fails! @@ -91,6 +96,8 @@ def main(): regexs["date"] = re.compile( '(2014|2015)' ) # strip // +build \n\n build constraints regexs["go_build_constraints"] = re.compile(r"^(// \+build.*\n)+\n", re.MULTILINE) + # strip #!.* from shell scripts + regexs["shebang"] = re.compile(r"^(#!.*\n)\n*", re.MULTILINE) for filename in filenames: if not file_passes(filename, extension, ref, regexs): diff --git a/hooks/boilerplate.sh.txt b/hooks/boilerplate.sh.txt index f592735e31e..6ce3fbd4645 100644 --- a/hooks/boilerplate.sh.txt +++ b/hooks/boilerplate.sh.txt @@ -1,5 +1,3 @@ -#!/bin/bash - # Copyright YEAR The Kubernetes Authors All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License");