-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Makefile: Use 'git diff' to show gofmt changes #1281
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
Conversation
|
Hi @wking. Thanks for your PR. I'm waiting for a openshift or kubernetes-incubator member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. DetailsInstructions 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. |
92a8a30 to
53cf0c3
Compare
53cf0c3 to
8dbc2d1
Compare
This makes fixing errors easier. Before this commit, errors looked
like [1]:
$ make gofmt
!!! 'gofmt -s' needs to be run on the following files:
./lib/config.go
make: *** [gofmt] Error 1
But that's not very helpful when your local gofmt thinks the file is
fine. With this commit, errors will look like:
$ make gofmt
find . -name '*.go' ! -path './vendor/*' -exec gofmt -s -w {} \+
git diff --exit-code
diff --git a/lib/config.go b/lib/config.go
index 1acca8c7..6a63b2b 100644
--- a/lib/config.go
+++ b/lib/config.go
@@ -2,7 +2,7 @@ package lib
import (
"bytes"
-"io/ioutil"
+ "io/ioutil"
"github.com/BurntSushi/toml"
"github.com/kubernetes-incubator/cri-o/oci"
make: *** [Makefile:68: gofmt] Error 1
(or whatever, I just stuffed in a formatting error for demonstration
purposes).
Also remove the helper script in favor of direct Makefile calls,
because with Git handling difference reporting and exit status, this
becomes a simpler check. find's -exec, !, and -path arguments are
specified in POSIX [2].
[1]: https://travis-ci.org/kubernetes-incubator/cri-o/jobs/331949394#L1075
[2]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html
Signed-off-by: W. Trevor King <[email protected]>
|
|
||
| gofmt: | ||
| @./hack/verify-gofmt.sh | ||
| find . -name '*.go' ! -path './vendor/*' -exec gofmt -s -w {} \+ |
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.
Isn't this actually running gofmt on the code? If so, it won't display any issues in the code in a PR.
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.
Isn't this actually running gofmt on the code?
Yes.
If so, it won't display any issues in the code in a PR.
Right. But the next line's git diff ... will show them (and return non-zero) if anything changed.
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.
Doesn't quite work for me locally:
[mrunalp@localhost cri-o]$ git diff
diff --git a/server/container_create.go b/server/container_create.go
index 506bcf79..492d8eea 100644
--- a/server/container_create.go
+++ b/server/container_create.go
@@ -295,7 +295,7 @@ func addDevices(sb *sandbox.Sandbox, containerConfig *pb.ContainerConfig, specge
UID: &hostDevice.Uid,
GID: &hostDevice.Gid,
}
- if hostDevice.Major == 0 && hostDevice.Minor == 0 {
+ if hostDevice.Major == 0 && hostDevice.Minor == 0 {
// Invalid device, most likely a symbolic link, skip it.
continue
}
[mrunalp@localhost cri-o]$ make gofmt
find . -name '*.go' ! -path './vendor/*' -exec gofmt -s -w {} \+
git diff --exit-code
[mrunalp@localhost cri-o]$ echo $?
0
[mrunalp@localhost cri-o]$ git diff
[mrunalp@localhost cri-o]$
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.
nvm, I see the point. It would have shown the bad changes if present in the bad commit.
mrunalp
left a comment
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
|
LGTM, neat little change! |
|
LGTM |
|
@wking: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions 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. I understand the commands that are listed here. |
|
this doesn't need e2e 😕 |
This makes fixing errors easier. Before this commit, errors looked like:
But that's not very helpful when your local
gofmtthinks the file is fine. With this commit, errors will look like:(or whatever, I just stuffed in a formatting error for demonstration purposes).