This commit is contained in:
r-ca 2023-12-16 14:03:39 +09:00
parent 3bab78883b
commit 5fd3a88b38
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -1,5 +1,6 @@
package one.nem.lacerta.source.jgit.impl; package one.nem.lacerta.source.jgit.impl;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import one.nem.lacerta.source.jgit.ActionRepo; import one.nem.lacerta.source.jgit.ActionRepo;
@ -8,6 +9,11 @@ public class ActionRepoImpl implements ActionRepo{
Repository repository; Repository repository;
// Internal method
private Git getGit() {
return new Git(repository);
}
@Override @Override
public void setRepository(Repository repository) { public void setRepository(Repository repository) {
this.repository = repository; this.repository = repository;
@ -15,23 +21,36 @@ public class ActionRepoImpl implements ActionRepo{
@Override @Override
public Repository getRepository() { public Repository getRepository() {
return null; if (repository == null) {
throw new RuntimeException("リポジトリが設定されていません");
}
return repository;
} }
@Override @Override
public String getRepositoryName() { public String getRepositoryName() {
return null; return repository.getDirectory().getParentFile().getName();
} }
@Override @Override
public String[] getUnstagedFiles() { public String[] getUnstagedFiles() {
Git git = new Git(repository);
try {
return git.status().call().getUntracked().toArray(new String[0]);
} catch (Exception e) { // TODO-rca: エラーハンドリング
return new String[0]; return new String[0];
} }
}
@Override @Override
public String[] getStagedFiles() { public String[] getStagedFiles() {
Git git = new Git(repository);
try {
return git.status().call().getAdded().toArray(new String[0]);
} catch (Exception e) { // TODO-rca: エラーハンドリング
return new String[0]; return new String[0];
} }
}
@Override @Override
public void stageFile(String path) { public void stageFile(String path) {