Skip to content

Commit

Permalink
Remove gitAddCommit unused method
Browse files Browse the repository at this point in the history
  • Loading branch information
DamnClin committed Jul 12, 2022
1 parent fb6972b commit aa3cec4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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> 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();
Expand Down

0 comments on commit aa3cec4

Please sign in to comment.