diff --git a/src/main/java/tech/jhipster/lite/generator/project/domain/ProjectRepository.java b/src/main/java/tech/jhipster/lite/generator/project/domain/ProjectRepository.java index 8665b2f439d..68c6269d3fd 100644 --- a/src/main/java/tech/jhipster/lite/generator/project/domain/ProjectRepository.java +++ b/src/main/java/tech/jhipster/lite/generator/project/domain/ProjectRepository.java @@ -24,7 +24,6 @@ public interface ProjectRepository { void setExecutable(Project project, String source, String sourceFilename); void gitInit(Project project); - void gitAddAndCommit(Project project, String message); void gitApplyPatch(Project project, String patchFilename); String zip(Project project); diff --git a/src/main/java/tech/jhipster/lite/generator/project/infrastructure/secondary/ProjectLocalRepository.java b/src/main/java/tech/jhipster/lite/generator/project/infrastructure/secondary/ProjectLocalRepository.java index 190af7a0497..dd22ad24596 100644 --- a/src/main/java/tech/jhipster/lite/generator/project/infrastructure/secondary/ProjectLocalRepository.java +++ b/src/main/java/tech/jhipster/lite/generator/project/infrastructure/secondary/ProjectLocalRepository.java @@ -185,15 +185,6 @@ public void gitInit(Project project) { } } - @Override - public void gitAddAndCommit(Project project, String message) { - try { - GitUtils.addAndCommit(project.getFolder(), message); - } catch (GitAPIException | IOException e) { - throw new GeneratorException("Error when git add and commit", e); - } - } - @Override public void gitApplyPatch(Project project, String patchFilename) { try { diff --git a/src/test/java/tech/jhipster/lite/generator/project/infrastructure/secondary/ProjectLocalRepositoryTest.java b/src/test/java/tech/jhipster/lite/generator/project/infrastructure/secondary/ProjectLocalRepositoryTest.java index a8b17ffb6ad..195a04ccdaf 100644 --- a/src/test/java/tech/jhipster/lite/generator/project/infrastructure/secondary/ProjectLocalRepositoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/project/infrastructure/secondary/ProjectLocalRepositoryTest.java @@ -1,13 +1,13 @@ package tech.jhipster.lite.generator.project.infrastructure.secondary; import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; import static tech.jhipster.lite.TestUtils.*; import static tech.jhipster.lite.common.domain.FileUtils.*; import static tech.jhipster.lite.generator.project.domain.Constants.*; import com.github.mustachejava.MustacheNotFoundException; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.CopyOption; @@ -314,30 +314,6 @@ void shouldNotGitInit() { } } - @Test - void shouldInitThenAddAndCommit() throws Exception { - Project project = tmpProject(); - - repository.gitInit(project); - File file = File.createTempFile("hello", ".world", new File(project.getFolder())); - repository.gitAddAndCommit(project, "1st commit"); - - assertFileExist(project, ".git"); - assertFileExist(project, file.getName()); - } - - @Test - void shouldNotAddAndCommit() { - Project project = tmpProject(); - - try (MockedStatic gitUtils = Mockito.mockStatic(GitUtils.class)) { - gitUtils.when(() -> GitUtils.addAndCommit(anyString(), anyString())).thenThrow(new InvalidConfigurationException("error")); - - assertThatThrownBy(() -> repository.gitAddAndCommit(project, "1st commit")).isExactlyInstanceOf(GeneratorException.class); - assertFileNotExist(project, ".git/config"); - } - } - @Test void shouldGitApplyPatch() { Project project = tmpProject();