Skip to content

ratchetFrom error: No such reference 'origin/master' #1242

Closed
@jingtang10

Description

@jingtang10

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

  • summary of problem
  • gradle or maven version
  • spotless version
  • operating system and version - NA
  • 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 - NA

If you're just submitting a feature request or question, no need for the above.

Please see google/android-fhir#1437.

AGP: 7.0.2
Gradle version: 7.4.1
Spotless version: 5.12.5

The code change works locally but not on github actions.

Worth noting we use submodules for the project.

See error: https://github.com/google/android-fhir/runs/6973816704?check_suite_focus=true

fun Project.configureSpotless() {
  val ktlintVersion = "0.41.0"
  val ktlintOptions = mapOf("indent_size" to "2", "continuation_indent_size" to "2")
  apply(plugin = Plugins.BuildPlugins.spotless)
  configure<com.diffplug.gradle.spotless.SpotlessExtension> {
    ratchetFrom = "origin/master" // only format files which have changed since origin/master
    kotlin {
      target("**/*.kt")
      targetExclude("**/build/")
      ktlint(ktlintVersion).userData(ktlintOptions)
      ktfmt().googleStyle()
      licenseHeaderFile(
        "${project.rootProject.projectDir}/license-header.txt",
        "package|import|class|object|sealed|open|interface|abstract "
        // It is necessary to tell spotless the top level of a file in order to apply config to it
        // See: https://github.com/diffplug/spotless/issues/135
        )
    }
    kotlinGradle {
      target("*.gradle.kts")
      ktlint(ktlintVersion).userData(ktlintOptions)
      ktfmt().googleStyle()
    }
    format("xml") {
      target("**/*.xml")
      targetExclude("**/build/", ".idea/")
      prettier(mapOf("prettier" to "2.0.5", "@prettier/plugin-xml" to "0.13.0"))
        .config(mapOf("parser" to "xml", "tabWidth" to 4))
    }
    // Creates one off SpotlessApply task for generated files
    com.diffplug.gradle.spotless.KotlinExtension(this).apply {
      target("**/*_Generated.kt")
      ktlint(ktlintVersion).userData(ktlintOptions)
      ktfmt().googleStyle()
      licenseHeaderFile(
        "${project.rootProject.projectDir}/license-header.txt",
        "package|import|class|object|sealed|open|interface|abstract "
      )
      createIndependentApplyTask("spotlessGenerated")
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions