checkstyle / contribution

some useful sources that should not stay in main repo but it is good to host them
GNU Lesser General Public License v2.1
49 stars 131 forks source link

diff.groovy throws IllegalStateException on not english locale #334

Open kazachka opened 6 years ago

kazachka commented 6 years ago

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 commented 6 years ago

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.

rnveach commented 6 years ago

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.