spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Mercurial equivalent for ratchetFrom

Open pinahar opened this issue 1 year ago • 2 comments

We have a large Kotlin project where we use spotless. However, it is pretty slow. I came across the ratchetFrom property but seems like it is only for Git. How can I make spotless run on just modified files to make the build faster?  

  • Gradle
  • spotless version - 6.23.3
  • operating system and version - Mac OSX 14.4.1

configure<com.diffplug.gradle.spotless.SpotlessExtension> { kotlin { target("/*.kt", "/.kts") targetExclude("$buildDir/**/", "/build//", "/node_modules//") ktfmt(findProperty("cbrKtfmtVersion")!! as String) } }

tasks.getByName("build") { group = "build" dependsOn("spotlessApply") }

pinahar avatar May 23 '24 00:05 pinahar

It's possible. My guess is that it would be best to parse mercurial's console output. If I was implementing it, I would do something along these lines:

class MercurialRatchet {
  String ratchetFrom;
  public String getShaOfHead() { } // or equivalent, used for up-to-date checking
  public boolean isClean(File file) { } // feel free to require more args than just this
}

and it would get integrated in these two places:

  • up-to-date checking
  • https://github.com/diffplug/spotless/blob/04d5f28c0401803323b3e8d82677fc081ab2b818/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTask.java#L74-L116
  • actual task execution
  • https://github.com/diffplug/spotless/blob/04d5f28c0401803323b3e8d82677fc081ab2b818/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTaskImpl.java#L81-L103

nedtwigg avatar May 23 '24 03:05 nedtwigg

Thanks for the response. How would I do this change locally? Not sure how that part would work.

pinahar avatar May 23 '24 08:05 pinahar