Skip to content

Commit b3c4893

Browse files
authored
Ignore external git config when running unit tests (#2021 fixes #1990)
2 parents 7770835 + 647f7e8 commit b3c4893

File tree

12 files changed

+91
-9
lines changed

12 files changed

+91
-9
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ This document is intended for Spotless developers.
1010
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
1111

1212
## [Unreleased]
13+
### Fixed
14+
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
1315

1416
## [2.45.0] - 2024-01-23
1517
### Added

lib-extra/src/test/java/com/diffplug/spotless/extra/GitAttributesTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,9 +27,11 @@
2727
import org.junit.jupiter.api.Test;
2828

2929
import com.diffplug.common.base.StringPrinter;
30+
import com.diffplug.spotless.ClearGitConfig;
3031
import com.diffplug.spotless.LineEnding;
3132
import com.diffplug.spotless.ResourceHarness;
3233

34+
@ClearGitConfig
3335
class GitAttributesTest extends ResourceHarness {
3436
private List<File> testFiles(String prefix) {
3537
List<File> result = new ArrayList<>();

lib-extra/src/test/java/com/diffplug/spotless/extra/GitRachetMergeBaseTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 DiffPlug
2+
* Copyright 2020-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,8 +27,10 @@
2727
import org.eclipse.jgit.lib.RefDatabase;
2828
import org.junit.jupiter.api.Test;
2929

30+
import com.diffplug.spotless.ClearGitConfig;
3031
import com.diffplug.spotless.ResourceHarness;
3132

33+
@ClearGitConfig
3234
class GitRachetMergeBaseTest extends ResourceHarness {
3335
@Test
3436
void test() throws IllegalStateException, GitAPIException, IOException {

lib-extra/src/test/java/com/diffplug/spotless/extra/GitWorkaroundsTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 DiffPlug
2+
* Copyright 2022-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,9 +27,11 @@
2727
import org.junit.jupiter.api.Nested;
2828
import org.junit.jupiter.api.Test;
2929

30+
import com.diffplug.spotless.ClearGitConfig;
3031
import com.diffplug.spotless.ResourceHarness;
3132
import com.diffplug.spotless.extra.GitWorkarounds.RepositorySpecificResolver;
3233

34+
@ClearGitConfig
3335
class GitWorkaroundsTest extends ResourceHarness {
3436
@Test
3537
void inline() throws IOException, GitAPIException {

plugin-gradle/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
44

55
## [Unreleased]
6+
### Fixed
7+
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
68

79
## [6.25.0] - 2024-01-23
810
### Added

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GitRatchetGradleTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,9 @@
3636
import org.junit.jupiter.params.ParameterizedTest;
3737
import org.junit.jupiter.params.provider.ValueSource;
3838

39+
import com.diffplug.spotless.ClearGitConfig;
40+
41+
@ClearGitConfig
3942
class GitRatchetGradleTest extends GradleIntegrationHarness {
4043
private static final String TEST_PATH = "src/markdown/test.md";
4144

@@ -268,10 +271,9 @@ public BuildResultAssertion outcome(String taskPath, TaskOutcome expected) {
268271
private RevCommit addAndCommit(Git git) throws NoFilepatternException, GitAPIException {
269272
PersonIdent emptyPerson = new PersonIdent("jane doe", "jane@doe.com", new Date(0), TimeZone.getTimeZone("UTC"));
270273
git.add().addFilepattern(".").call();
271-
RevCommit commit = git.commit().setMessage("baseline")
274+
return git.commit().setMessage("baseline")
272275
.setCommitter(emptyPerson)
273276
.setAuthor(emptyPerson)
274277
.call();
275-
return commit;
276278
}
277279
}

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/LicenseHeaderTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,9 @@
2121
import org.eclipse.jgit.api.Git;
2222
import org.junit.jupiter.api.Test;
2323

24+
import com.diffplug.spotless.ClearGitConfig;
25+
26+
@ClearGitConfig
2427
class LicenseHeaderTest extends GradleIntegrationHarness {
2528
private static final String NOW = String.valueOf(YearMonth.now().getYear());
2629

plugin-maven/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
44

55
## [Unreleased]
6+
### Fixed
7+
* Ignore system git config when running tests ([#1990](https://github.com/diffplug/spotless/issues/1990))
68

79
## [2.43.0] - 2024-01-23
810
### Added

plugin-maven/src/test/java/com/diffplug/spotless/maven/GitRatchetMavenTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 DiffPlug
2+
* Copyright 2020-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,7 +25,9 @@
2525
import org.junit.jupiter.api.Test;
2626

2727
import com.diffplug.common.base.StringPrinter;
28+
import com.diffplug.spotless.ClearGitConfig;
2829

30+
@ClearGitConfig
2931
class GitRatchetMavenTest extends MavenIntegrationHarness {
3032
private static final String TEST_PATH = "src/markdown/test.md";
3133

plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderRatchetTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 DiffPlug
2+
* Copyright 2020-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,8 +21,10 @@
2121
import org.eclipse.jgit.api.Git;
2222
import org.junit.jupiter.api.Test;
2323

24+
import com.diffplug.spotless.ClearGitConfig;
2425
import com.diffplug.spotless.maven.MavenIntegrationHarness;
2526

27+
@ClearGitConfig
2628
class LicenseHeaderRatchetTest extends MavenIntegrationHarness {
2729
private static final String NOW = String.valueOf(YearMonth.now().getYear());
2830

0 commit comments

Comments
 (0)