Skip to content

Commit

Permalink
make checkstyle happy
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSnoozer committed Mar 2, 2024
1 parent 76696dc commit 6097668
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/main/java/pl/project13/maven/git/GitDirLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ private File processGitDirFile(@Nonnull File file) {
/**
* Attempts to resolve the actual location of the .git folder for a given
* worktree.
* For example for a worktree like {@code a/.git/worktrees/X} structure would return {@code a/.git}.
* For example for a worktree like {@code a/.git/worktrees/X} structure would
* return {@code a/.git}.
*
* If the conditions for a git worktree like file structure are met simply return the provided
* argument as is.
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/pl/project13/maven/git/GitDirLocatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public void shouldResolveRelativeSubmodule() throws Exception {

// and a .git dir in submodule that points to the main's project .git/modules/submodule
File dotGitDir = folder.getRoot().toPath()
.resolve("main-project")
.resolve("sub-module")
.resolve(".git")
.toFile();
.resolve("main-project")
.resolve("sub-module")
.resolve(".git")
.toFile();
Files.write(
dotGitDir.toPath(),
"gitdir: ../.git/modules/sub-module".getBytes()
dotGitDir.toPath(),
"gitdir: ../.git/modules/sub-module".getBytes()
);

try {
Expand All @@ -87,9 +87,9 @@ public void shouldResolveRelativeSubmodule() throws Exception {
// then
assertThat(foundDirectory).isNotNull();
assertThat(
foundDirectory.getCanonicalFile()
foundDirectory.getCanonicalFile()
).isEqualTo(
folder.getRoot().toPath()
folder.getRoot().toPath()
.resolve("main-project")
.resolve(".git")
.resolve("modules")
Expand Down
8 changes: 6 additions & 2 deletions src/test/java/pl/project13/maven/git/GitIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nonnull;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -164,7 +168,7 @@ private static List<MavenProject> getReactorProjects(@Nonnull MavenProject proje
}

public static void assertPropertyPresentAndEqual(
Properties properties, String key, String expected) {
Properties properties, String key, String expected) {
assertThat(properties.stringPropertyNames()).contains(key);
assertThat(properties.getProperty(key)).isEqualTo(expected);
}
Expand Down
22 changes: 12 additions & 10 deletions src/test/java/pl/project13/maven/git/GitSubmodulesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package pl.project13.maven.git;

import java.nio.file.Files;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.apache.maven.project.MavenProject;
Expand All @@ -34,7 +33,8 @@ public class GitSubmodulesTest extends GitIntegrationTest {

@Test
@Parameters(method = "useNativeGit")
public void shouldResolvePropertiesOnDefaultSettingsForNonPomProject(boolean useNativeGit) throws Exception {
public void shouldResolvePropertiesOnDefaultSettingsForNonPomProject(
boolean useNativeGit) throws Exception {
mavenSandbox
.withParentProject("my-jar-project", "jar")
.withGitRepoInParent(AvailableGitTestRepo.WITH_SUBMODULES)
Expand All @@ -57,18 +57,19 @@ public void shouldResolvePropertiesOnDefaultSettingsForNonPomProject(boolean use
public void shouldGeneratePropertiesWithSubmodules(boolean useNativeGit) throws Exception {
// given
mavenSandbox
.withParentProject("my-pom-project", "pom")
.withGitRepoInParent(AvailableGitTestRepo.WITH_REMOTE_SUBMODULES)
.withChildProject("remote-module", "jar")
.create();
.withParentProject("my-pom-project", "pom")
.withGitRepoInParent(AvailableGitTestRepo.WITH_REMOTE_SUBMODULES)
.withChildProject("remote-module", "jar")
.create();
MavenProject targetProject = mavenSandbox.getChildProject();
setProjectToExecuteMojoIn(targetProject);

// create a relative pointer to trigger the relative path logic in GitDirLocator#lookupGitDirectory
// create a relative pointer to trigger the relative path logic in
// GitDirLocator#lookupGitDirectory
// makes the dotGitDirectory look like "my-pom-project/.git/modules/remote-module"
Files.write(
mavenSandbox.getChildProject().getBasedir().toPath().resolve(".git"),
"gitdir: ../.git/modules/remote-module".getBytes()
mavenSandbox.getChildProject().getBasedir().toPath().resolve(".git"),
"gitdir: ../.git/modules/remote-module".getBytes()
);

mojo.useNativeGit = useNativeGit;
Expand All @@ -77,6 +78,7 @@ public void shouldGeneratePropertiesWithSubmodules(boolean useNativeGit) throws
mojo.execute();

// then
assertPropertyPresentAndEqual(targetProject.getProperties(), "git.commit.id.abbrev", "945bfe6");
assertPropertyPresentAndEqual(
targetProject.getProperties(), "git.commit.id.abbrev", "945bfe6");
}
}

0 comments on commit 6097668

Please sign in to comment.