Commit 6664da20 authored by liaozan's avatar liaozan 🏀

chore: remove unnecessary checkouts

parent 03c29c40
...@@ -5,10 +5,8 @@ import cn.hutool.system.SystemUtil; ...@@ -5,10 +5,8 @@ import cn.hutool.system.SystemUtil;
import com.schbrain.archetype.initializer.maven.MavenUtils; import com.schbrain.archetype.initializer.maven.MavenUtils;
import com.schbrain.common.exception.BaseException; import com.schbrain.common.exception.BaseException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.jgit.api.CheckoutCommand;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.TagOpt; import org.eclipse.jgit.transport.TagOpt;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
...@@ -46,17 +44,13 @@ public class ArchetypePreparer implements ApplicationRunner { ...@@ -46,17 +44,13 @@ public class ArchetypePreparer implements ApplicationRunner {
private void checkoutArchetype(File archetypeTemplateDirectory) { private void checkoutArchetype(File archetypeTemplateDirectory) {
try { try {
Git git = Git.cloneRepository() Git.cloneRepository()
.setTagOption(TagOpt.FETCH_TAGS) .setTagOption(TagOpt.FETCH_TAGS)
.setNoCheckout(false) .setNoCheckout(false)
.setDirectory(archetypeTemplateDirectory) .setDirectory(archetypeTemplateDirectory)
.setCloneSubmodules(false)
.setURI(ARCHETYPE_REPO_URL) .setURI(ARCHETYPE_REPO_URL)
.setRemote("upstream")
.call(); .call();
CheckoutCommand checkoutCommand = git.checkout().setName("archetype").setCreateBranch(true); log.info("Success checkout archetype from {}", ARCHETYPE_REPO_URL);
Ref ref = checkoutCommand.call();
log.info("Success checkout archetype branch: {} of {}", ref.getName(), ARCHETYPE_REPO_URL);
} catch (GitAPIException e) { } catch (GitAPIException e) {
throw new BaseException("Failed to checkout archetype from git repository", e); throw new BaseException("Failed to checkout archetype from git repository", e);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment