From 4de33b95507ef6de1dbdfeb9649a70e47d14b72a 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, 16 Jan 2024 12:53:04 +0900 Subject: [PATCH] =?UTF-8?q?JGit=E9=96=A2=E9=80=A3=E3=81=AE=E3=83=A2?= =?UTF-8?q?=E3=82=B8=E3=83=A5=E3=83=BC=E3=83=AB=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/source/jgit/ActionRepo.java | 31 ------ .../lacerta/source/jgit/JGitRepository.java | 17 --- .../source/jgit/impl/ActionRepoImpl.java | 101 ------------------ .../source/jgit/impl/JGitRepositoryImpl.java | 55 ---------- .../nem/lacerta/source/jgit/impl/placeholder | 0 .../jgit/module/JGitRepositoryModule.java | 15 --- .../lacerta/source/jgit/module/placeholder | 0 7 files changed, 219 deletions(-) delete mode 100644 source/src/main/java/one/nem/lacerta/source/jgit/ActionRepo.java delete mode 100644 source/src/main/java/one/nem/lacerta/source/jgit/JGitRepository.java delete mode 100644 source/src/main/java/one/nem/lacerta/source/jgit/impl/ActionRepoImpl.java delete mode 100644 source/src/main/java/one/nem/lacerta/source/jgit/impl/JGitRepositoryImpl.java delete mode 100644 source/src/main/java/one/nem/lacerta/source/jgit/impl/placeholder delete mode 100644 source/src/main/java/one/nem/lacerta/source/jgit/module/JGitRepositoryModule.java delete mode 100644 source/src/main/java/one/nem/lacerta/source/jgit/module/placeholder diff --git a/source/src/main/java/one/nem/lacerta/source/jgit/ActionRepo.java b/source/src/main/java/one/nem/lacerta/source/jgit/ActionRepo.java deleted file mode 100644 index 6bb6f830..00000000 --- a/source/src/main/java/one/nem/lacerta/source/jgit/ActionRepo.java +++ /dev/null @@ -1,31 +0,0 @@ -package one.nem.lacerta.source.jgit; - -import org.eclipse.jgit.lib.Repository; - -public interface ActionRepo { - - // リポジトリをインスタンス変数に格納 - void setRepository(Repository repository); - - // リポジトリ取得 - Repository getRepository(); - - // リポジトリ名取得 - String getRepositoryName(); - - // ステージングされていないファイルの一覧を取得 - String[] getUnstagedFiles(); - - // ステージングされているファイルの一覧を取得 - String[] getStagedFiles(); - - // ファイルをステージング - void stageFile(String path); - - // ファイルをアンステージング - void unstageFile(String path); - - // ステージングされているファイルをコミット - void commit(String message); - -} diff --git a/source/src/main/java/one/nem/lacerta/source/jgit/JGitRepository.java b/source/src/main/java/one/nem/lacerta/source/jgit/JGitRepository.java deleted file mode 100644 index 09d04f17..00000000 --- a/source/src/main/java/one/nem/lacerta/source/jgit/JGitRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package one.nem.lacerta.source.jgit; - -import org.eclipse.jgit.lib.Repository; - -public interface JGitRepository { - - // リポジトリ取得 - Repository getRepository(String id); - // リポジトリ作成 - Repository createRepository(String id); - // リポジトリ削除 - void deleteRepository(String id); - // リポジトリ存在確認 - boolean repositoryExists(String id); - - -} diff --git a/source/src/main/java/one/nem/lacerta/source/jgit/impl/ActionRepoImpl.java b/source/src/main/java/one/nem/lacerta/source/jgit/impl/ActionRepoImpl.java deleted file mode 100644 index ac94b96f..00000000 --- a/source/src/main/java/one/nem/lacerta/source/jgit/impl/ActionRepoImpl.java +++ /dev/null @@ -1,101 +0,0 @@ -package one.nem.lacerta.source.jgit.impl; - -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.lib.Repository; - -import javax.inject.Inject; - -import one.nem.lacerta.source.jgit.ActionRepo; -import one.nem.lacerta.utils.LacertaLogger; - -public class ActionRepoImpl implements ActionRepo{ - - @Inject // Inject logger - LacertaLogger logger; - - private final String TAG = "ActionRepoImpl"; - - Repository repository; - - Git git; - - // Internal method - private Git getGit() { - if (this.git == null) { - logger.debug(TAG, "getGit: git is null. Creating new Git instance"); - this.git = new Git(repository); - } - return this.git; - } - - @Override - public void setRepository(Repository repository) { - this.repository = repository; - } - - @Override - public Repository getRepository() { - if (repository == null) { - logger.warn(TAG, "getRepository: repository is null. Throwing RuntimeException"); - throw new RuntimeException("リポジトリが設定されていません"); - } - return repository; - } - - @Override - public String getRepositoryName() { - return repository.getDirectory().getParentFile().getName(); - } - - @Override - public String[] getUnstagedFiles() { - Git git = getGit(); - try { - return git.status().call().getUntracked().toArray(new String[0]); - } catch (Exception e) { // TODO-rca: エラーハンドリング - logger.error(TAG, "getUnstagedFiles: " + e.getMessage()); - return new String[0]; - } - } - - @Override - public String[] getStagedFiles() { - Git git = getGit(); - try { - return git.status().call().getAdded().toArray(new String[0]); - } catch (Exception e) { // TODO-rca: エラーハンドリング - logger.error(TAG, "getStagedFiles: " + e.getMessage()); - return new String[0]; - } - } - - @Override - public void stageFile(String path) { - Git git = getGit(); - try { - git.add().addFilepattern(path).call(); - } catch (Exception e) { // TODO-rca: エラーハンドリング - logger.error(TAG, "stageFile: " + e.getMessage()); - } - } - - @Override - public void unstageFile(String path) { - Git git = getGit(); - try { - git.reset().addPath(path).call(); - } catch (Exception e) { // TODO-rca: エラーハンドリング - logger.error(TAG, "unstageFile: " + e.getMessage()); - } - } - - @Override - public void commit(String message) { - Git git = getGit(); - try { - git.commit().setMessage(message).call(); - } catch (Exception e) { // TODO-rca: エラーハンドリング - logger.error(TAG, "commit: " + e.getMessage()); - } - } -} diff --git a/source/src/main/java/one/nem/lacerta/source/jgit/impl/JGitRepositoryImpl.java b/source/src/main/java/one/nem/lacerta/source/jgit/impl/JGitRepositoryImpl.java deleted file mode 100644 index fabcb0bb..00000000 --- a/source/src/main/java/one/nem/lacerta/source/jgit/impl/JGitRepositoryImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package one.nem.lacerta.source.jgit.impl; - -import one.nem.lacerta.source.jgit.JGitRepository; - -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 JGitRepositoryImpl implements JGitRepository { - - private final DeviceInfoUtils deviceInfoUtils; - - @Inject - public JGitRepositoryImpl(DeviceInfoUtils deviceInfoUtils) { - this.deviceInfoUtils = deviceInfoUtils; - } - - @Override - public Repository getRepository(String id) { - 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) { - 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; // TODO-rca: 未実装 - } -} diff --git a/source/src/main/java/one/nem/lacerta/source/jgit/impl/placeholder b/source/src/main/java/one/nem/lacerta/source/jgit/impl/placeholder deleted file mode 100644 index e69de29b..00000000 diff --git a/source/src/main/java/one/nem/lacerta/source/jgit/module/JGitRepositoryModule.java b/source/src/main/java/one/nem/lacerta/source/jgit/module/JGitRepositoryModule.java deleted file mode 100644 index 4c9b8fde..00000000 --- a/source/src/main/java/one/nem/lacerta/source/jgit/module/JGitRepositoryModule.java +++ /dev/null @@ -1,15 +0,0 @@ -package one.nem.lacerta.source.jgit.module; - -import dagger.Binds; -import dagger.Module; -import dagger.hilt.InstallIn; -import dagger.hilt.components.SingletonComponent; -import one.nem.lacerta.source.jgit.JGitRepository; - -@Module -@InstallIn(SingletonComponent.class) -abstract public class JGitRepositoryModule { - - @Binds - public abstract JGitRepository bindManageRepo(one.nem.lacerta.source.jgit.impl.JGitRepositoryImpl manageRepoImpl); -} diff --git a/source/src/main/java/one/nem/lacerta/source/jgit/module/placeholder b/source/src/main/java/one/nem/lacerta/source/jgit/module/placeholder deleted file mode 100644 index e69de29b..00000000