mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2026-11-07 19:47:36 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d686ce776 |
No files matched your search
Generated
+1
@@ -25,6 +25,7 @@
|
|||||||
<option value="$PROJECT_DIR$/model" />
|
<option value="$PROJECT_DIR$/model" />
|
||||||
<option value="$PROJECT_DIR$/processor" />
|
<option value="$PROJECT_DIR$/processor" />
|
||||||
<option value="$PROJECT_DIR$/shared" />
|
<option value="$PROJECT_DIR$/shared" />
|
||||||
|
<option value="$PROJECT_DIR$/shared/icon" />
|
||||||
<option value="$PROJECT_DIR$/shared/ui" />
|
<option value="$PROJECT_DIR$/shared/ui" />
|
||||||
<option value="$PROJECT_DIR$/source" />
|
<option value="$PROJECT_DIR$/source" />
|
||||||
<option value="$PROJECT_DIR$/utils" />
|
<option value="$PROJECT_DIR$/utils" />
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 概要
|
||||||
|
<!-- PRの概要 -->
|
||||||
|
|
||||||
|
# 関連Issue
|
||||||
|
- #000 <!-- 関連するIssueを指定(なければ省略可) -->
|
||||||
|
|
||||||
|
# 詳細
|
||||||
|
<!-- 詳細 -->
|
||||||
|
|
||||||
|
# 影響箇所
|
||||||
|
<!-- 予想される影響箇所 -->
|
||||||
|
|
||||||
|
# チェック
|
||||||
|
<!-- 参考用, 全てにチェックがついている必要があるわけではありません -->
|
||||||
|
- [ ] 機能として完成している
|
||||||
|
- [ ] WIP(Work in progress: 作業中)
|
||||||
|
- [ ] 正常にビルド/起動ができる
|
||||||
|
- [ ] 既存の機能を壊していない
|
||||||
@@ -83,6 +83,8 @@ dependencies {
|
|||||||
|
|
||||||
implementation project(':shared:ui')
|
implementation project(':shared:ui')
|
||||||
|
|
||||||
|
implementation project(':shared:icon')
|
||||||
|
|
||||||
// Hilt (DI)
|
// Hilt (DI)
|
||||||
implementation libs.com.google.dagger.hilt.android
|
implementation libs.com.google.dagger.hilt.android
|
||||||
annotationProcessor libs.com.google.dagger.hilt.compiler
|
annotationProcessor libs.com.google.dagger.hilt.compiler
|
||||||
|
|||||||
@@ -2,27 +2,32 @@ package one.nem.lacerta.data.impl;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
// Hilt
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
// Lacerta/data
|
|
||||||
import one.nem.lacerta.data.Document;
|
import one.nem.lacerta.data.Document;
|
||||||
|
|
||||||
// Lacerta/model
|
|
||||||
import one.nem.lacerta.model.PublicPath;
|
import one.nem.lacerta.model.PublicPath;
|
||||||
import one.nem.lacerta.model.document.DocumentMeta;
|
import one.nem.lacerta.model.document.DocumentMeta;
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
|
|
||||||
// Lacerta/source
|
import one.nem.lacerta.model.document.path.DocumentPath;
|
||||||
|
import one.nem.lacerta.model.document.tag.DocumentTag;
|
||||||
import one.nem.lacerta.source.database.LacertaDatabase;
|
import one.nem.lacerta.source.database.LacertaDatabase;
|
||||||
|
|
||||||
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
import one.nem.lacerta.source.database.entity.DocumentEntity;
|
||||||
|
import one.nem.lacerta.source.database.entity.LibraryEntity;
|
||||||
|
import one.nem.lacerta.source.database.entity.TagEntity;
|
||||||
|
|
||||||
// Lacerta/utils
|
import one.nem.lacerta.source.database.entity.VcsLogEntity;
|
||||||
|
import one.nem.lacerta.vcs.ActionType;
|
||||||
|
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
||||||
|
import one.nem.lacerta.source.jgit.JGitRepository;
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
import one.nem.lacerta.utils.XmlMetaParser;
|
||||||
// Lacerta/vcs
|
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
||||||
import one.nem.lacerta.vcs.LacertaVcs;
|
import one.nem.lacerta.vcs.LacertaVcs;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<application>
|
||||||
|
<activity
|
||||||
|
android:name=".DebugMenuContainerActivity"
|
||||||
|
android:exported="false" />
|
||||||
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -3,30 +3,27 @@ package one.nem.lacerta.processor.impl;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
// Hilt
|
|
||||||
import dagger.assisted.Assisted;
|
import dagger.assisted.Assisted;
|
||||||
import dagger.assisted.AssistedInject;
|
import dagger.assisted.AssistedInject;
|
||||||
|
import one.nem.lacerta.model.document.internal.XmlMetaPageModel;
|
||||||
// Lacerta/model
|
|
||||||
import one.nem.lacerta.model.document.DocumentDetail;
|
|
||||||
import one.nem.lacerta.model.document.internal.XmlMetaModel;
|
|
||||||
import one.nem.lacerta.model.document.page.Page;
|
|
||||||
|
|
||||||
// Lacerta/processor
|
|
||||||
import one.nem.lacerta.processor.DocumentProcessor;
|
import one.nem.lacerta.processor.DocumentProcessor;
|
||||||
|
|
||||||
// Lacerta/source
|
import one.nem.lacerta.model.document.DocumentDetail;
|
||||||
|
|
||||||
|
import one.nem.lacerta.model.document.internal.XmlMetaModel;
|
||||||
|
|
||||||
|
import one.nem.lacerta.model.document.page.Page;
|
||||||
|
|
||||||
import one.nem.lacerta.source.file.FileManager;
|
import one.nem.lacerta.source.file.FileManager;
|
||||||
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
import one.nem.lacerta.source.file.factory.FileManagerFactory;
|
||||||
|
|
||||||
// Lacerta/utils
|
|
||||||
import one.nem.lacerta.utils.LacertaLogger;
|
import one.nem.lacerta.utils.LacertaLogger;
|
||||||
|
|
||||||
import one.nem.lacerta.utils.XmlMetaParser;
|
import one.nem.lacerta.utils.XmlMetaParser;
|
||||||
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
import one.nem.lacerta.utils.repository.DeviceInfoUtils;
|
||||||
|
|
||||||
// Lacerta/vcs
|
|
||||||
import one.nem.lacerta.vcs.LacertaVcs;
|
import one.nem.lacerta.vcs.LacertaVcs;
|
||||||
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
import one.nem.lacerta.vcs.factory.LacertaVcsFactory;
|
||||||
|
|
||||||
|
|||||||
@@ -30,4 +30,5 @@ include ':source'
|
|||||||
include ':model'
|
include ':model'
|
||||||
include ':processor'
|
include ':processor'
|
||||||
include ':shared:ui'
|
include ':shared:ui'
|
||||||
|
include ':shared:icon'
|
||||||
include ':vcs'
|
include ':vcs'
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
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: 未実装
|
||||||
|
}
|
||||||
|
}
|
||||||
Whitespace-only changes.
@@ -0,0 +1,15 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
Whitespace-only changes.
Reference in new issue
Block a user