Skip to content

Commit

Permalink
Fix boilerplate for sh to allow alt shebangs
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Jul 1, 2015
1 parent ceaddc0 commit 38bddc2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 8 additions & 1 deletion hooks/boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions hooks/boilerplate.sh.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

# Copyright YEAR The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down

0 comments on commit 38bddc2

Please sign in to comment.