Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip version file detection with document files #43

Merged
merged 1 commit into from
Aug 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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