mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Allow boilerplate checks on whole filenames
This commit is contained in:
parent
8d8de2efb4
commit
6a5157b496
@ -33,6 +33,7 @@ rootdir = os.path.abspath(rootdir)
|
|||||||
|
|
||||||
def get_refs():
|
def get_refs():
|
||||||
refs = {}
|
refs = {}
|
||||||
|
|
||||||
for path in glob.glob(os.path.join(rootdir, "hack/boilerplate/boilerplate.*.txt")):
|
for path in glob.glob(os.path.join(rootdir, "hack/boilerplate/boilerplate.*.txt")):
|
||||||
extension = os.path.basename(path).split(".")[1]
|
extension = os.path.basename(path).split(".")[1]
|
||||||
|
|
||||||
@ -52,8 +53,12 @@ def file_passes(filename, refs, regexs):
|
|||||||
data = f.read()
|
data = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
basename = os.path.basename(filename)
|
||||||
extension = file_extension(filename)
|
extension = file_extension(filename)
|
||||||
ref = refs[extension]
|
if extension != "":
|
||||||
|
ref = refs[extension]
|
||||||
|
else:
|
||||||
|
ref = refs[basename]
|
||||||
|
|
||||||
# remove build tags from the top of Go files
|
# remove build tags from the top of Go files
|
||||||
if extension == "go":
|
if extension == "go":
|
||||||
@ -128,8 +133,9 @@ def get_files(extensions):
|
|||||||
files = normalize_files(files)
|
files = normalize_files(files)
|
||||||
outfiles = []
|
outfiles = []
|
||||||
for pathname in files:
|
for pathname in files:
|
||||||
|
basename = os.path.basename(pathname)
|
||||||
extension = file_extension(pathname)
|
extension = file_extension(pathname)
|
||||||
if extension in extensions:
|
if extension in extensions or basename in extensions:
|
||||||
outfiles.append(pathname)
|
outfiles.append(pathname)
|
||||||
return outfiles
|
return outfiles
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user