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

View File

@ -9,9 +9,14 @@ public class ActionRepoImpl implements ActionRepo{
Repository repository; Repository repository;
Git git;
// Internal method // Internal method
private Git getGit() { private Git getGit() {
return new Git(repository); if (this.git == null) {
this.git = new Git(repository);
}
return this.git;
} }
@Override @Override
@ -34,7 +39,7 @@ public class ActionRepoImpl implements ActionRepo{
@Override @Override
public String[] getUnstagedFiles() { public String[] getUnstagedFiles() {
Git git = new Git(repository); Git git = getGit();
try { try {
return git.status().call().getUntracked().toArray(new String[0]); return git.status().call().getUntracked().toArray(new String[0]);
} catch (Exception e) { // TODO-rca: エラーハンドリング } catch (Exception e) { // TODO-rca: エラーハンドリング
@ -44,7 +49,7 @@ public class ActionRepoImpl implements ActionRepo{
@Override @Override
public String[] getStagedFiles() { public String[] getStagedFiles() {
Git git = new Git(repository); Git git = getGit();
try { try {
return git.status().call().getAdded().toArray(new String[0]); return git.status().call().getAdded().toArray(new String[0]);
} catch (Exception e) { // TODO-rca: エラーハンドリング } catch (Exception e) { // TODO-rca: エラーハンドリング