-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
✨ Make directory-not-empty error more self-explanatory #1943
✨ Make directory-not-empty error more self-explanatory #1943
Conversation
361a400
to
ada8cd3
Compare
ada8cd3
to
b71349c
Compare
pkg/plugins/golang/v3/init.go
Outdated
@@ -188,7 +187,7 @@ func checkDir() error { | |||
return err | |||
} | |||
if info.Name() != "go.mod" && !strings.HasPrefix(info.Name(), ".") { | |||
return errors.New("only the go.mod and files with the prefix \"(.)\" are allowed before the init") | |||
return fmt.Errorf("target directory is not empty: found existing file %q", path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: I think the file name should be enough
return fmt.Errorf("target directory is not empty: found existing file %q", path) | |
return fmt.Errorf("target directory is not empty: found existing file %q", info.Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started with that actually and switched to path :-) The root cause here was that we were finding files like .git/HEAD
. info.Name() prints "HEAD", but path prints ".git/HEAD".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not still clarifying what files are allowed? See that any file with the prefix (.) is allowed. E.g. .gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought was that maybe the user doesn't care, but it is a good idea to try to reference the idea that some files are allowed, so I added it back! Thanks!
/retest pull-kubebuilder-e2e-k8s-1-16-2 I can't see how that failure could be related, so rolling the dice again! |
@justinsb: The
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test pull-kubebuilder-e2e-k8s-1-16-2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
My only question is the one raised in #1944 (comment) /lgtm |
When I encountered the error, I had to go to the source to understand the problem. Made the message more user-focused. Also skipped printing the allowlist, both to fit into lint line-length limits and to avoid overwhelming the user.
b71349c
to
20df76b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: estroz, justinsb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold cancel |
When I encountered the error, I had to go to the source to understand
the problem. Made the message more user-focused.
Also skipped printing the allowlist, both to fit into lint line-length
limits and to avoid overwhelming the user.