From 669df94c5da9d3673297a3f5cd5beea5c4504fb3 Mon Sep 17 00:00:00 2001 From: matthieulapatate Date: Mon, 28 Feb 2022 12:16:40 +0100 Subject: [PATCH] Add git initialisation when creating a project. --- .../init/application/InitApplicationService.java | 4 ++++ .../lite/generator/init/domain/InitDomainService.java | 6 ++++++ .../lite/generator/init/domain/InitService.java | 1 + .../init/application/InitApplicationServiceIT.java | 10 ++++++++++ .../generator/init/application/InitAssertFiles.java | 5 +++++ 5 files changed, 26 insertions(+) diff --git a/src/main/java/tech/jhipster/lite/generator/init/application/InitApplicationService.java b/src/main/java/tech/jhipster/lite/generator/init/application/InitApplicationService.java index ceebe27a4d3..8130538588c 100644 --- a/src/main/java/tech/jhipster/lite/generator/init/application/InitApplicationService.java +++ b/src/main/java/tech/jhipster/lite/generator/init/application/InitApplicationService.java @@ -36,4 +36,8 @@ public void addEditorConfiguration(Project project) { public void addPrettier(Project project) { initService.addPrettier(project); } + + public void gitInit(Project project) { + initService.gitInit(project); + } } diff --git a/src/main/java/tech/jhipster/lite/generator/init/domain/InitDomainService.java b/src/main/java/tech/jhipster/lite/generator/init/domain/InitDomainService.java index fc4bdbe7cb6..e51988360b4 100644 --- a/src/main/java/tech/jhipster/lite/generator/init/domain/InitDomainService.java +++ b/src/main/java/tech/jhipster/lite/generator/init/domain/InitDomainService.java @@ -33,6 +33,7 @@ public void init(Project project) { addEditorConfiguration(project); addPrettier(project); addPackageJson(project); + gitInit(project); } @Override @@ -110,4 +111,9 @@ public void addPrettier(Project project) { project.addConfig("prettierEndOfLine", CRLF.equals(project.getEndOfLine()) ? "crlf" : "lf"); projectRepository.template(project, SOURCE, ".prettierrc"); } + + @Override + public void gitInit(Project project) { + projectRepository.gitInit(project); + } } diff --git a/src/main/java/tech/jhipster/lite/generator/init/domain/InitService.java b/src/main/java/tech/jhipster/lite/generator/init/domain/InitService.java index 6238e8f9c7b..80a16e8f321 100644 --- a/src/main/java/tech/jhipster/lite/generator/init/domain/InitService.java +++ b/src/main/java/tech/jhipster/lite/generator/init/domain/InitService.java @@ -10,4 +10,5 @@ public interface InitService { void addGitConfiguration(Project project); void addEditorConfiguration(Project project); void addPrettier(Project project); + void gitInit(Project project); } diff --git a/src/test/java/tech/jhipster/lite/generator/init/application/InitApplicationServiceIT.java b/src/test/java/tech/jhipster/lite/generator/init/application/InitApplicationServiceIT.java index 5373fbebb96..582347cba7c 100644 --- a/src/test/java/tech/jhipster/lite/generator/init/application/InitApplicationServiceIT.java +++ b/src/test/java/tech/jhipster/lite/generator/init/application/InitApplicationServiceIT.java @@ -55,6 +55,7 @@ void shouldInitWithConfig() { ) ); // @formatter:on + assertFileGitInit(project); } @Test @@ -128,4 +129,13 @@ void shouldAddPrettier() { assertFilesPrettier(project); } + + @Test + void shouldGitInit() { + Project project = tmpProject(); + + initApplicationService.gitInit(project); + + assertFileGitInit(project); + } } diff --git a/src/test/java/tech/jhipster/lite/generator/init/application/InitAssertFiles.java b/src/test/java/tech/jhipster/lite/generator/init/application/InitAssertFiles.java index e90a44260d5..defbd004d0c 100644 --- a/src/test/java/tech/jhipster/lite/generator/init/application/InitAssertFiles.java +++ b/src/test/java/tech/jhipster/lite/generator/init/application/InitAssertFiles.java @@ -56,4 +56,9 @@ public static void assertFilesInit(Project project) { assertFilesEditorConfiguration(project); assertFilesPrettier(project); } + + public static void assertFileGitInit(Project project) { + assertFileExist(project, ".git/config"); + assertFileExist(project, ".git/HEAD"); + } }