contribution icon indicating copy to clipboard operation
contribution copied to clipboard

diff.groovy throws IllegalStateException on not english locale

Open kazachka opened this issue 7 years ago • 2 comments

When executing on another (not english) locale, diff.groove throws IllegalStateException with message: Caught: java.lang.IllegalStateException: Error: git repository /home/kazachka/checkstyle has unstaged changes! Exception is throwing from here: https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/diff.groovy#L12 caused because localized git message doesn't contain english text "nothing to commit", so hasUnstagedChanges function returns true. https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/diff.groovy#L156

kazachka avatar Sep 11 '18 18:09 kazachka

The command is:

groovy diff.groovy -r /home/zenigata/workspace/checkstyle/ -b upstream/master -p class-fan-out-complexity-check -c ./my_check.xml -l projects-to-test-on.properties

The output is:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/usr/share/groovy/lib/groovy-2.4.15.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Caught: java.lang.IllegalStateException: Error: git repository /home/zenigata/workspace/checkstyle has unstaged changes!
java.lang.IllegalStateException: Error: git repository /home/zenigata/workspace/checkstyle has unstaged changes!
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at diff.run(diff.groovy:12)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

appears on ru-Ru locale. Adding -Duser.language=en -Duser.country=US parameters doesn't help.

kazachka avatar Sep 23 '18 11:09 kazachka

Adding -Duser.language=en -Duser.country=US parameters doesn't help.

This is because groovy executes another command inside of it (checkstyle/git) and it only passes specific parameters to the other commands.

If you can help us with a fix, feel free to create a PR. I currently don't know if we can tell git to report messages in other languages, or if there is a better way to check for unstaged files.

rnveach avatar Sep 23 '18 17:09 rnveach