ログ追加

This commit is contained in:
r-ca 2023-12-16 14:22:38 +09:00
parent 43b0dd4eed
commit 132991122f
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -3,10 +3,18 @@ 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;
@ -14,6 +22,7 @@ public class ActionRepoImpl implements ActionRepo{
// 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;
@ -27,6 +36,7 @@ public class ActionRepoImpl implements ActionRepo{
@Override
public Repository getRepository() {
if (repository == null) {
logger.warn(TAG, "getRepository: repository is null. Throwing RuntimeException");
throw new RuntimeException("リポジトリが設定されていません");
}
return repository;
@ -43,6 +53,7 @@ public class ActionRepoImpl implements ActionRepo{
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];
}
}
@ -53,6 +64,7 @@ public class ActionRepoImpl implements ActionRepo{
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];
}
}