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