Skip to content

Commit

Permalink
Merge pull request #43 from Songmu/versionfiledetection
Browse files Browse the repository at this point in the history
skip version file detection with document files
  • Loading branch information
Songmu authored Aug 20, 2022
2 parents fc3027d + 6eff835 commit 333f6ed
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 333f6ed

Please sign in to comment.