Skip to content

Commit 285f94c

Browse files
committed
Thankyou Spotbugs for catching this!
1 parent f6449b4 commit 285f94c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/src/main/java/com/diffplug/spotless/generic/LicenseHeaderStep.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.diffplug.spotless.LineEnding;
4141
import com.diffplug.spotless.OnMatch;
4242
import com.diffplug.spotless.SerializableFileFilter;
43+
import com.diffplug.spotless.SerializedFunction;
4344
import com.diffplug.spotless.ThrowingEx;
4445

4546
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@@ -119,13 +120,22 @@ public LicenseHeaderStep withSkipLinesMatching(@Nullable String skipLinesMatchin
119120
return new LicenseHeaderStep(name, contentPattern, headerLazy, delimiter, yearSeparator, yearMode, skipLinesMatching);
120121
}
121122

123+
private static class SetLicenseHeaderYearsFromGitHistory implements SerializedFunction<Runtime, FormatterFunc> {
124+
private static final long serialVersionUID = 1L;
125+
126+
@Override
127+
public FormatterFunc apply(Runtime input) throws Exception {
128+
return FormatterFunc.needsFile(input::setLicenseHeaderYearsFromGitHistory);
129+
}
130+
}
131+
122132
public FormatterStep build() {
123133
FormatterStep formatterStep;
124134
if (yearMode.get() == YearMode.SET_FROM_GIT) {
125135
formatterStep = FormatterStep.createLazy(name, () -> {
126136
boolean updateYear = false; // doesn't matter
127137
return new Runtime(headerLazy.get(), delimiter, yearSeparator, updateYear, skipLinesMatching);
128-
}, step -> FormatterFunc.needsFile(step::format));
138+
}, new SetLicenseHeaderYearsFromGitHistory());
129139
} else {
130140
formatterStep = FormatterStep.createLazy(name, () -> {
131141
// by default, we should update the year if the user is using ratchetFrom

0 commit comments

Comments
 (0)