Squashed commit of the following:
commit 06c248b843151906dce6f2aa499e5aa521ad3147
Author: duohedron <kopi@duohedron.com>
Date: Mon Oct 7 16:20:56 2019 +0200
Revert travis.yml
commit 18f8d2f1985834f1bd95e271e009b55b2d18c3fb
Author: duohedron <kopi@duohedron.com>
Date: Mon Oct 7 16:14:46 2019 +0200
Switch lint and boilerplate in .travis.yml
commit e75dd2434da804649f5a0b6169f819037efd59ae
Author: duohedron <kopi@duohedron.com>
Date: Mon Oct 7 16:10:48 2019 +0200
Fix env in .travis.yml
commit 94d105f50b8555e01303857dcb9ded0785dbd122
Author: duohedron <kopi@duohedron.com>
Date: Mon Oct 7 15:55:22 2019 +0200
Fix fileExtension in boilerplate.go
commit b1b4e8145fc20c8a2a4e062b98f455206983b1d5
Author: duohedron <kopi@duohedron.com>
Date: Mon Oct 7 14:50:26 2019 +0200
Fix absolute path containing skipped dirs in boilerplate.go
commit 52f8d62688d3289d4210ebd2ac81116c38aaf2fa
Author: duohedron <kopi@duohedron.com>
Date: Mon Oct 7 14:00:33 2019 +0200
Modify Travis CI to use one VM instead of three
commit 99534ebe4c84f78dac12f2bc8b423143c6a79258
Author: duohedron <kopi@duohedron.com>
Date: Mon Oct 7 13:59:28 2019 +0200
Changed fix.sh to use go run
commit dd3fd243341666e5d47d105fb2d25eedfecf1c74
Author: duohedron <kopi@duohedron.com>
Date: Mon Oct 7 13:37:08 2019 +0200
Change go build to go run in test.sh
commit 2d5f22b826c205d2cbf5e9e0909555198c19d85f
Author: duohedron <kopi@duohedron.com>
Date: Mon Oct 7 13:23:55 2019 +0200
Fix whitespaces and function names
pull/5544/head
parent
a0215e0ce8
commit
2e4512ea18
|
|
@ -47,9 +47,9 @@ func main() {
|
|||
if len(refs) == 0 {
|
||||
log.Fatal("no references in ", *boilerplatedir)
|
||||
}
|
||||
files := getFileList(*rootdir, refs)
|
||||
files := filesToCheck(*rootdir, refs)
|
||||
for _, file := range files {
|
||||
if !filePasses(file, refs[getFileExtension(file)]) {
|
||||
if !filePasses(file, refs[fileExtension(file)]) {
|
||||
fmt.Println(file)
|
||||
}
|
||||
}
|
||||
|
|
@ -64,12 +64,13 @@ func getRefs(dir string) map[string][]byte {
|
|||
refs := make(map[string][]byte)
|
||||
files, _ := filepath.Glob(dir + "/*.txt")
|
||||
for _, filename := range files {
|
||||
extension := strings.ToLower(strings.Split(filename, ".")[1])
|
||||
re := regexp.MustCompile(`\.txt`)
|
||||
extension := strings.ToLower(fileExtension(re.ReplaceAllString(filename, "")))
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
re := regexp.MustCompile(`\r`)
|
||||
re = regexp.MustCompile(`\r`)
|
||||
refs[extension] = re.ReplaceAll(data, nil)
|
||||
}
|
||||
return refs
|
||||
|
|
@ -90,7 +91,7 @@ func filePasses(filename string, ref []byte) bool {
|
|||
re = regexp.MustCompile(`\r`)
|
||||
data = re.ReplaceAll(data, nil)
|
||||
|
||||
extension := getFileExtension(filename)
|
||||
extension := fileExtension(filename)
|
||||
|
||||
// remove build tags from the top of Go files
|
||||
if extension == "go" {
|
||||
|
|
@ -127,7 +128,7 @@ func filePasses(filename string, ref []byte) bool {
|
|||
/**
|
||||
Function to get the file extensin or the filename if the file has no extension
|
||||
*/
|
||||
func getFileExtension(filename string) string {
|
||||
func fileExtension(filename string) string {
|
||||
splitted := strings.Split(filepath.Base(filename), ".")
|
||||
return strings.ToLower(splitted[len(splitted)-1])
|
||||
}
|
||||
|
|
@ -135,11 +136,16 @@ func getFileExtension(filename string) string {
|
|||
/**
|
||||
Function to get all the files from the directory that heeds to be checked.
|
||||
*/
|
||||
func getFileList(rootDir string, extensions map[string][]byte) []string {
|
||||
func filesToCheck(rootDir string, extensions map[string][]byte) []string {
|
||||
var outFiles []string
|
||||
err := filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error {
|
||||
if !info.IsDir() && !skippedPaths.MatchString(filepath.Dir(path)) {
|
||||
if extensions[strings.ToLower(getFileExtension(path))] != nil {
|
||||
// remove current workdir from the beginnig of the path in case it matches the skipped path
|
||||
cwd, _ := os.Getwd()
|
||||
// replace "\" with "\\" for windows style path
|
||||
re := regexp.MustCompile(`\\`)
|
||||
re = regexp.MustCompile(`^` + re.ReplaceAllString(cwd, `\\`))
|
||||
if !info.IsDir() && !skippedPaths.MatchString(re.ReplaceAllString(filepath.Dir(path), "")) {
|
||||
if extensions[strings.ToLower(fileExtension(path))] != nil {
|
||||
outFiles = append(outFiles, path)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ function prepend() {
|
|||
local pattern=$1
|
||||
local ref=$2
|
||||
local headers=$3
|
||||
local files=$(hack/boilerplate/boilerplate -rootdir ${ROOT_DIR} -boilerplate-dir ${ROOT_DIR}/hack/boilerplate | grep -v "$ignore" | grep "$pattern")
|
||||
pushd hack/boilerplate > /dev/null
|
||||
local files=$(go run boilerplate.go -rootdir ${ROOT_DIR} -boilerplate-dir ${ROOT_DIR}/hack/boilerplate | grep -v "$ignore" | grep "$pattern")
|
||||
popd > /dev/null
|
||||
for f in ${files}; do
|
||||
echo ${f};
|
||||
local copyright="$(cat hack/boilerplate/boilerplate.${ref}.txt | sed s/YEAR/$(date +%Y)/g)"
|
||||
|
|
|
|||
9
test.sh
9
test.sh
|
|
@ -33,11 +33,10 @@ fi
|
|||
if [[ "$TESTSUITE" = "boilerplate" ]] || [[ "$TESTSUITE" = "all" ]]
|
||||
then
|
||||
echo "= boilerplate ==========================================================="
|
||||
readonly BDIR="./hack/boilerplate"
|
||||
pushd ${BDIR}
|
||||
go build
|
||||
popd
|
||||
missing="$(${BDIR}/boilerplate -rootdir . -boilerplate-dir ${BDIR} | egrep -v '/assets.go|/translations.go|/site/themes/|/site/node_modules|\./out|/hugo/' || true)"
|
||||
readonly ROOT_DIR=$(pwd)
|
||||
readonly BDIR="${ROOT_DIR}/hack/boilerplate"
|
||||
cd ${BDIR}
|
||||
missing="$(go run boilerplate.go -rootdir ${ROOT_DIR} -boilerplate-dir ${BDIR} | egrep -v '/assets.go|/translations.go|/site/themes/|/site/node_modules|\./out|/hugo/' || true)"
|
||||
if [[ -n "${missing}" ]]; then
|
||||
echo "boilerplate missing: $missing"
|
||||
echo "consider running: ${BDIR}/fix.sh"
|
||||
|
|
|
|||
Loading…
Reference in New Issue