Describe the bug
The diffSource.git.compareWith configuration has no effect if the files have not been committed to git.
If this is by design, it should be clearly documented. However, it does not align with the expectation of executing git diff <ref> and saving the results to a file that the plugin points to. In particular, it makes a diff reference to HEAD completely useless after the commit.
Additionally the comment in the config explicitly specifies uncommitted files:
Compares current HEAD and all uncommited with provided branch
Desktop (please complete the following information):
- OS: Mac OS X 13.0 x86_64
- Gradle version: 7.5.1
- Diff Coverage plugin version 0.9.5
To Reproduce
- Make changes to a file that require coverage, save them but do not commit.
gradle diffCoverage with the below configuration
diffCoverageReport {
diffSource {
git.compareWith 'refs/remotes/origin/main'
}
reports {
html = true
}
}
- Observe the files in
build/reports/jacoco directory:
Expected behavior
Changed files are found and diff.patch is not empty.
Additional context
Workaround is to configure:
diffSource {
file = 'build/tmp/git.diff'
}
and then execute:
git diff refs/remotes/origin/main > build/tmp/git.diff
gradle diffCoverage
Describe the bug
The
diffSource.git.compareWithconfiguration has no effect if the files have not been committed to git.If this is by design, it should be clearly documented. However, it does not align with the expectation of executing
git diff <ref>and saving the results to a file that the plugin points to. In particular, it makes a diff reference toHEADcompletely useless after the commit.Additionally the comment in the config explicitly specifies uncommitted files:
Desktop (please complete the following information):
To Reproduce
gradle diffCoveragewith the below configurationdiffCoverageReport { diffSource { git.compareWith 'refs/remotes/origin/main' } reports { html = true } }build/reports/jacocodirectory:diff.patchfile has 0 bytesdiffCoverage/html/index.htmlsays "No class files specified." (See also report in diffCoverage gives html report with "No class files specified." #65 for which this may have been the cause.)Expected behavior
Changed files are found and
diff.patchis not empty.Additional context
Workaround is to configure:
diffSource { file = 'build/tmp/git.diff' }and then execute:
git diff refs/remotes/origin/main > build/tmp/git.diff gradle diffCoverage