From 4ed88e8facb77177c8b2e85154ebdc68bf11075d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Thu, 14 Dec 2023 14:36:21 +0900 Subject: [PATCH] =?UTF-8?q?WIP=20Impl=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/jgit/impl/ManageRepoImpl.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/source/src/main/java/one/nem/lacerta/source/jgit/impl/ManageRepoImpl.java b/source/src/main/java/one/nem/lacerta/source/jgit/impl/ManageRepoImpl.java index 5a802893..d1b9c845 100644 --- a/source/src/main/java/one/nem/lacerta/source/jgit/impl/ManageRepoImpl.java +++ b/source/src/main/java/one/nem/lacerta/source/jgit/impl/ManageRepoImpl.java @@ -4,26 +4,51 @@ import one.nem.lacerta.source.jgit.ManageRepo; import javax.inject.Inject; +import one.nem.lacerta.utils.repository.DeviceInfoUtils; + import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.lib.RepositoryBuilder; + public class ManageRepoImpl implements ManageRepo { + private final DeviceInfoUtils deviceInfoUtils; + + @Inject + public ManageRepoImpl(DeviceInfoUtils deviceInfoUtils) { + this.deviceInfoUtils = deviceInfoUtils; + } + @Override public Repository getRepository(String id) { - return null; + RepositoryBuilder repositoryBuilder = new RepositoryBuilder(); + repositoryBuilder.setGitDir(deviceInfoUtils.getExternalStorageDirectory().resolve(id).resolve(".git").toFile()); + repositoryBuilder.setMustExist(true); + try { + return repositoryBuilder.build(); + } catch (Exception e) { + return null; + } } @Override public Repository createRepository(String id) { - return null; + RepositoryBuilder repositoryBuilder = new RepositoryBuilder(); + repositoryBuilder.setGitDir(deviceInfoUtils.getExternalStorageDirectory().resolve(id).resolve(".git").toFile()); + repositoryBuilder.setMustExist(false); + try { + return repositoryBuilder.build(); + } catch (Exception e) { + return null; + } } @Override public void deleteRepository(String id) { - + // TODO-rca: 未実装 } @Override public boolean repositoryExists(String id) { - return false; + return false; // TODO-rca: 未実装 } }