Skip to content

Commit

Permalink
skip version file detection with document files
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Aug 20, 2022
1 parent fc3027d commit 6eff835
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions versionfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,34 @@ const versionRegBase = `(?i)((?:^|[^-_0-9a-zA-Z])version[^-_0-9a-zA-Z].{0,20})`

var (
versionReg = regexp.MustCompile(versionRegBase + `([0-9]+\.[0-9]+\.[0-9]+)`)
// The "testdata" directory is ommited because of the test code for rcpr itself
skipDirs = map[string]bool{
".git": true,
skipDirs = map[string]bool{
// The "testdata" directory is ommited because of the test code for rcpr itself
"testdata": true,
".git": true,
"node_modules": true,
"vendor": true,
"third_party": true,
"extlib": true,
"docs": true,
// The directory for storing python test code, but it may be inappropriate to omit this directory
// uniformly because it may be used by test libraries for other languages.
"tests": true,
}
skipFiles = map[string]bool{
"requirements.txt": true,
"cpanfile.snapshot": true,
"package-lock.json": true,
}
skipExt = map[string]bool{
".md": true,
".rst": true,
".adoc": true,
}
)

func isSkipFile(n string) bool {
n = strings.ToLower(n)
return strings.HasSuffix(n, ".lock") || skipFiles[n]
return strings.HasSuffix(n, ".lock") || skipFiles[n] || skipExt[filepath.Ext(n)]
}

func detectVersionFile(root string, ver *semv) (string, error) {
Expand Down

0 comments on commit 6eff835

Please sign in to comment.