Skip to content

Gradle configuration error when remote git branch is pruned in CI job #1157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 of 6 tasks
ZSmallX opened this issue Mar 30, 2022 · 1 comment
Closed
5 of 6 tasks
Labels

Comments

@ZSmallX
Copy link

ZSmallX commented Mar 30, 2022

If you are submitting a bug, please include the following:

  • summary of problem: Gradle configuration error when remote git branch is pruned in CI job
  • gradle or maven version: Gradle 6.8
  • spotless version: 6.3.0
  • operating system and version: currenly unknown for it's CI job, investigate later.
  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
  • copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace

I'm trying to build a package as aritifact on non-master branch. And it seems CI job had pruned the remote branch origin/master. But spotless still check the remote branch during Gradle configuration(evaluateing) time, which causes an error.

Spotless configuration block(s)

spotless {
        ratchetFrom 'origin/master'

        java {
            target 'src/*/java/**/*.java'
            toggleOffOn()
            googleJavaFormat('1.15.0')
        }

        kotlin {
            toggleOffOn()
            target '**/*.kt'
            ktfmt('0.34').googleStyle()
        }
    }
2022/03/30 16:45:21 Cause 1: java.lang.IllegalArgumentException: No such reference 'origin/master'
2022/03/30 16:45:21 	at com.diffplug.spotless.extra.GitRatchet.rootTreeShaOf(GitRatchet.java:211)
2022/03/30 16:45:21 	at com.diffplug.gradle.spotless.SpotlessTask.setupRatchet(SpotlessTask.java:94)
2022/03/30 16:45:21 	at com.diffplug.gradle.spotless.FormatExtension.setupTask(FormatExtension.java:763)
2022/03/30 16:45:21 	at com.diffplug.gradle.spotless.JavaExtension.setupTask(JavaExtension.java:256)
2022/03/30 16:45:21 	at com.diffplug.gradle.spotless.SpotlessExtensionImpl.lambda$createFormatTasks$6(SpotlessExtensionImpl.java:73)
2022/03/30 16:45:21 	at org.gradle.api.internal.DefaultMutationGuard$2.execute(DefaultMutationGuard.java:44)
2022/03/30 16:45:21 	at org.gradle.api.internal.DefaultMutationGuard$2.execute(DefaultMutationGuard.java:44)

Should spotless check the remote branch during task execution time rather than configuration time?

@nedtwigg
Copy link
Member

Should spotless check the remote branch during task execution time rather than configuration time?

The ratchet point is used as part of up-to-date checking, which requires origin/master to be resolved at configuration time. #710 is the long-term fix for this, and you can find tips on deep vs shallow clones there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants