You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* - For best performance, you should have one instance of GitRatchet, shared by all projects.
52
+
* - Use {@link #rootTreeShaOf(Object, String)} to turn `origin/master` into the SHA of the tree object at that reference
53
+
* - Use {@link #isClean(Object, ObjectId, File)} to see if the given file is "git clean" relative to that tree
54
+
* - If you have up-to-date checking and want the best possible performance, use {@link #subtreeShaOf(Object, ObjectId)} to optimize up-to-date checks on a per-project basis.
Copy file name to clipboardExpand all lines: plugin-maven/CHANGES.md
+2-1
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
4
4
5
5
## [Unreleased]
6
6
### Added
7
-
*`prettier` will now autodetect the parser (and formatter) to use based on the filename, unless you override this using `config` or `configFile` with the option `parser` or `filepath` ([#620](https://github.com/diffplug/spotless/pull/620)).
7
+
*You can now ratchet a project's style by limiting Spotless only to files which have changed since a given [git reference](https://javadoc.io/static/org.eclipse.jgit/org.eclipse.jgit/5.6.1.202002131546-r/org/eclipse/jgit/lib/Repository.html#resolve-java.lang.String-), e.g. `ratchetFrom 'origin/main'`. ([#590](https://github.com/diffplug/spotless/pull/590))
8
8
* Huge speed improvement for multi-module projects thanks to improved cross-project classloader caching ([#571](https://github.com/diffplug/spotless/pull/571), fixes [#559](https://github.com/diffplug/spotless/issues/559)).
9
+
*`prettier` will now autodetect the parser (and formatter) to use based on the filename, unless you override this using `config` or `configFile` with the option `parser` or `filepath` ([#620](https://github.com/diffplug/spotless/pull/620)).
Copy file name to clipboardExpand all lines: plugin-maven/README.md
+21-1
Original file line number
Diff line number
Diff line change
@@ -594,7 +594,25 @@ By default, `spotless:check` is bound to the `verify` phase. You might want to
594
594
- If you don't like what spotless did, `git reset --hard`
595
595
- If you'd like to remove the "checkpoint" commit, `git reset --soft head~1` will make the checkpoint commit "disappear" from history, but keeps the changes in your working directory.
596
596
597
-
<aname="examples"></a>
597
+
<aname="ratchet"></a>
598
+
599
+
## How can I enforce formatting gradually?
600
+
601
+
If your project is not currently enforcing formatting, then it can be a noisy transition. Having a giant commit where every single file gets changed makes the history harder to read. To address this, you can use the `ratchet` feature:
602
+
603
+
```xml
604
+
<configuration>
605
+
<ratchetFrom>origin/main</ratchetFrom> <!-- only format files which have changed since origin/main -->
606
+
<!-- ... define formats ... -->
607
+
</configuration>
608
+
```
609
+
610
+
In this mode, Spotless will apply only to files which have changed since `origin/main`. You can ratchet from [any point you want](https://javadoc.io/static/org.eclipse.jgit/org.eclipse.jgit/5.6.1.202002131546-r/org/eclipse/jgit/lib/Repository.html#resolve-java.lang.String-), even `HEAD`. You can also set `ratchetFrom` per-format if you prefer (e.g. `<configuration><java><ratchetFrom>...`).
611
+
612
+
However, we strongly recommend that you use a non-local branch, such as a tag or `origin/main`. The problem with `HEAD` or any local branch is that as soon as you commit a file, that is now the canonical formatting, even if it was formatted incorrectly. By instead specifying `origin/main` or a tag, your CI server will fail unless every changed file is at least as good or better than it was before the change.
613
+
614
+
This is especially helpful for injecting accurate copyright dates using the [license step](#license-header).
0 commit comments