mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-19 21:45:25 +00:00
Fix magefile exclusion handling.
This commit is contained in:
parent
dfc644214b
commit
c4cf666dbe
36
magefile.go
36
magefile.go
@ -178,23 +178,43 @@ func init() {
|
|||||||
Log("Concurrency:", concurrency)
|
Log("Concurrency:", concurrency)
|
||||||
goSrc = func() []string {
|
goSrc = func() []string {
|
||||||
results := new([]string)
|
results := new([]string)
|
||||||
filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
|
filepath.Walk(".", func(relpath string, info os.FileInfo, err error) error {
|
||||||
|
// Ensure absolute path so globs work
|
||||||
|
path, err := filepath.Abs(relpath)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Look for files
|
// Look for files
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exclusions
|
// Exclusions
|
||||||
if matched, _ := filepath.Match("*/vendor/*", path); matched {
|
for _, exclusion := range []string{toolDir, binDir, releaseDir, coverageDir} {
|
||||||
|
if strings.HasPrefix(path, exclusion) {
|
||||||
|
if info.IsDir() {
|
||||||
|
return filepath.SkipDir
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
} else if matched, _ := filepath.Match(fmt.Sprintf("%s/*", toolDir), path); matched {
|
}
|
||||||
return nil
|
}
|
||||||
} else if matched, _ := filepath.Match(fmt.Sprintf("%s/*", binDir), path); matched {
|
|
||||||
return nil
|
if strings.Contains(path, "/vendor/") {
|
||||||
} else if matched, _ := filepath.Match(fmt.Sprintf("%s/*", releaseDir), path); matched {
|
if info.IsDir() {
|
||||||
|
return filepath.SkipDir
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if matched, _ := filepath.Match("*.go", path); !matched {
|
if strings.Contains(path, ".git") {
|
||||||
|
if info.IsDir() {
|
||||||
|
return filepath.SkipDir
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.HasSuffix(path, ".go") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user