violations-gradle-plugin icon indicating copy to clipboard operation
violations-gradle-plugin copied to clipboard

[Question] How to use diffing?

Open sgrekov opened this issue 4 years ago • 5 comments

Hi! First of all, thank you for the library, it looks great! I am trying diffing feature, and I cannot make it work with the provided sample. I created a new branch https://github.com/sgrekov/violations-gradle-plugin/commits/diff_check and made a changes to report, and try to run diff command. ./gradlew violations -i -PdiffFrom=35f88688c8049558da9b408519cc5e52c9d7099c -PdiffTo=aca1d7232ba2fdc8c8b1c393dbfa7a47fd9dc6b5 The expected outcome for me is that this task will finish with failure, but it is not, it only show violations from the report and finished with success. Am I missing something? Or maybe I am using it wrong?

sgrekov avatar Apr 23 '21 15:04 sgrekov

This code may help understand it: https://github.com/tomasbjerre/violations-git-lib/blob/master/src/main/java/se/bjurr/violations/git/ViolationsGit.java

It will parse git commits to find the files that differ. And count reported errors on changed lines in those files.

You would need to change the files also, not only the report-files.

tomasbjerre avatar Apr 24 '21 06:04 tomasbjerre

So that means that in order diff start complaining about violations relative to branch 'git diff ' command must contain references to those files? I added files to the branches(and changed paths in reports accordingly) and try to run ./gradlew violations -i -PdiffTo=master -PdiffFrom=diff_check and still no luck(

sgrekov avatar Apr 30 '21 14:04 sgrekov

This works:

./gradlew violations -i -PdiffTo=diff_check -PdiffFrom=master

But I agree that the from/to seems more logical in your command!

tomasbjerre avatar May 01 '21 07:05 tomasbjerre

Hmm, isn't it the way it supposed to work? According to your comments in the build file ./gradlew check -PdiffFrom=$TRAVIS_PULL_REQUEST_BRANCH -PdiffTo=$TRAVIS_BRANCH it should be the opposite, no?

sgrekov avatar May 02 '21 12:05 sgrekov

Yes should probably be opposite.

tomasbjerre avatar May 02 '21 12:05 tomasbjerre