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

use fi.Mode().IsRegular() #32

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
rcpr
dist/
6 changes: 5 additions & 1 deletion rcpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ func detectVersionFile(root string, ver *semv) (string, error) {
}

errorCb := func(fpath string, err error) error {
// When running a rcpr binary under the repository root, "text file busy" occurred,
// so I did error handling as this, but it did not solve the problem, and it is a special case,
// so we may not need to do the check in particular.
if os.IsPermission(err) || errors.Is(err, syscall.ETXTBSY) {
return nil
}
Expand All @@ -420,12 +423,13 @@ func detectVersionFile(root string, ver *semv) (string, error) {
fl := &fileList{}
if err := walker.Walk(root, func(fpath string, fi os.FileInfo) error {
if fi.IsDir() {
// The "testdata" directory is ommited because of the test code for rcpr itself
if fi.Name() == ".git" || fi.Name() == "testdata" {
return filepath.SkipDir
}
return nil
}
if fi.Mode()&os.ModeSymlink != 0 {
if !fi.Mode().IsRegular() {
return nil
}
joinedPath := filepath.Join(root, fpath)
Expand Down
6 changes: 4 additions & 2 deletions rcpr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (
)

func TestDetectVersionFile(t *testing.T) {
v, _ := newSemver("0.0.0")
v, _ := newSemver(version)
f, err := detectVersionFile(".", v)
if err != nil {
t.Error(err)
}
t.Log(f)
if f != "version.go" {
t.Errorf("error")
}
}

func TestRetrieveVersionFile(t *testing.T) {
Expand Down