-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
12 changed files
with
91 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2016-2023 DiffPlug | ||
* Copyright 2016-2024 DiffPlug | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -36,6 +36,9 @@ | |
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import com.diffplug.spotless.ClearGitConfig; | ||
|
||
@ClearGitConfig | ||
class GitRatchetGradleTest extends GradleIntegrationHarness { | ||
private static final String TEST_PATH = "src/markdown/test.md"; | ||
|
||
|
@@ -268,10 +271,9 @@ public BuildResultAssertion outcome(String taskPath, TaskOutcome expected) { | |
private RevCommit addAndCommit(Git git) throws NoFilepatternException, GitAPIException { | ||
PersonIdent emptyPerson = new PersonIdent("jane doe", "[email protected]", new Date(0), TimeZone.getTimeZone("UTC")); | ||
git.add().addFilepattern(".").call(); | ||
RevCommit commit = git.commit().setMessage("baseline") | ||
return git.commit().setMessage("baseline") | ||
.setCommitter(emptyPerson) | ||
.setAuthor(emptyPerson) | ||
.call(); | ||
return commit; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
testlib/src/main/java/com/diffplug/spotless/ClearGitConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2024 DiffPlug | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.diffplug.spotless; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.util.List; | ||
|
||
import org.eclipse.jgit.lib.StoredConfig; | ||
import org.eclipse.jgit.util.SystemReader; | ||
import org.junit.jupiter.api.extension.AfterEachCallback; | ||
import org.junit.jupiter.api.extension.BeforeEachCallback; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.parallel.ResourceAccessMode; | ||
import org.junit.jupiter.api.parallel.ResourceLock; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@ExtendWith(ClearGitConfig.GitConfigExtension.class) | ||
@ResourceLock(value = "GIT", mode = ResourceAccessMode.READ_WRITE) | ||
public @interface ClearGitConfig { | ||
|
||
class GitConfigExtension implements BeforeEachCallback, AfterEachCallback { | ||
|
||
@Override | ||
public void beforeEach(ExtensionContext extensionContext) throws Exception { | ||
for (var config : getConfigs()) { | ||
config.clear(); | ||
} | ||
} | ||
|
||
@Override | ||
public void afterEach(ExtensionContext extensionContext) throws Exception { | ||
for (var config : getConfigs()) { | ||
config.load(); | ||
} | ||
} | ||
|
||
private static List<StoredConfig> getConfigs() throws Exception { | ||
var reader = SystemReader.getInstance(); | ||
return List.of(reader.getUserConfig(), reader.getSystemConfig()); | ||
} | ||
} | ||
} |