From 5fd3a88b3851a855fbcca6f15e76a7e71ae62364 Mon Sep 17 00:00:00 2001 From: r-ca Date: Sat, 16 Dec 2023 14:03:39 +0900 Subject: [PATCH] WIP --- .../source/jgit/impl/ActionRepoImpl.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) 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 index 9399861a..53d8033a 100644 --- 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 @@ -1,5 +1,6 @@ package one.nem.lacerta.source.jgit.impl; +import org.eclipse.jgit.api.Git; import org.eclipse.jgit.lib.Repository; import one.nem.lacerta.source.jgit.ActionRepo; @@ -8,6 +9,11 @@ public class ActionRepoImpl implements ActionRepo{ Repository repository; + // Internal method + private Git getGit() { + return new Git(repository); + } + @Override public void setRepository(Repository repository) { this.repository = repository; @@ -15,22 +21,35 @@ public class ActionRepoImpl implements ActionRepo{ @Override public Repository getRepository() { - return null; + if (repository == null) { + throw new RuntimeException("リポジトリが設定されていません"); + } + return repository; } @Override public String getRepositoryName() { - return null; + return repository.getDirectory().getParentFile().getName(); } @Override public String[] getUnstagedFiles() { - return new String[0]; + Git git = new Git(repository); + try { + return git.status().call().getUntracked().toArray(new String[0]); + } catch (Exception e) { // TODO-rca: エラーハンドリング + return new String[0]; + } } @Override public String[] getStagedFiles() { - return new String[0]; + Git git = new Git(repository); + try { + return git.status().call().getAdded().toArray(new String[0]); + } catch (Exception e) { // TODO-rca: エラーハンドリング + return new String[0]; + } } @Override