From 31fcdd788adfa9cbe3021b807bbf38d403456d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Tue, 12 Dec 2023 11:35:28 +0900 Subject: [PATCH] =?UTF-8?q?DebugFunc=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/data/impl/DebugFuncImpl.java | 25 ++++++++++++++++++- .../lacerta/data/repository/DebugFunc.java | 7 +++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/data/src/main/java/one/nem/lacerta/data/impl/DebugFuncImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/DebugFuncImpl.java index 10ae885c..98685f0f 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/DebugFuncImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/DebugFuncImpl.java @@ -1,4 +1,27 @@ package one.nem.lacerta.data.impl; -public class DebugFuncImpl { +import org.eclipse.jgit.lib.Repository; + +import javax.inject.Inject; + +import one.nem.lacerta.data.repository.DebugFunc; +import one.nem.lacerta.source.jgit.RepoUtils; +import one.nem.lacerta.utils.repository.FileUtils; + +public class DebugFuncImpl implements DebugFunc { + + @Inject + public DebugFuncImpl() { + } + + @Inject + RepoUtils repoUtils; + + public Repository getOrCreateRepositoryById(String id) { + Repository repo = repoUtils.getRepo(id); // TODO-rca: リポジトリの存在確認をもうすこしなんとかする + if (repo == null) { + repo = repoUtils.createRepo(id); + } + return repo; + } } diff --git a/data/src/main/java/one/nem/lacerta/data/repository/DebugFunc.java b/data/src/main/java/one/nem/lacerta/data/repository/DebugFunc.java index 24752b3c..5cb2c247 100644 --- a/data/src/main/java/one/nem/lacerta/data/repository/DebugFunc.java +++ b/data/src/main/java/one/nem/lacerta/data/repository/DebugFunc.java @@ -1,4 +1,9 @@ package one.nem.lacerta.data.repository; -public class DebugFunc { +import org.eclipse.jgit.lib.Repository; + +public interface DebugFunc { + + Repository getOrCreateRepositoryById(String id); + }