Skip to content

Commit

Permalink
Fix diffCoverage GHA on non-PR (#251)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>

Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis authored Nov 15, 2022
1 parent f897f15 commit 015b4e4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,16 @@ jacocoTestReport {
// https://github.com/form-com/diff-coverage-gradle/issues/73
ext.createDiffFile = { ->
def file = Files.createTempFile(URLEncoder.encode(project.name, 'UTF-8'), '.diff').toFile()
// ref for local runs
def diffBase = 'refs/remotes/origin/main'
if (System.getenv('CI')) {
diffBase = 'origin/' + System.getenv('GITHUB_BASE_REF')
if (System.getenv('GITHUB_BASE_REF')) {
// we are on a PR
diffBase = 'origin/' + System.getenv('GITHUB_BASE_REF')
} else {
// we are on main branch, no diff
diffBase = 'HEAD'
}
}
file.withOutputStream { out ->
exec {
Expand Down

0 comments on commit 015b4e4

Please sign in to comment.