mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
Remove some uses of the Settings singleton
It needs to be removed from everywhere.
This commit is contained in:
@ -6,7 +6,6 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:git_bindings/git_bindings.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
|
||||
//
|
||||
@ -16,6 +15,8 @@ Future migrateGitRepo({
|
||||
@required String gitBasePath,
|
||||
@required String fromGitBasePath,
|
||||
@required String toGitBaseFolder,
|
||||
@required String gitAuthor,
|
||||
@required String gitAuthorEmail,
|
||||
}) async {
|
||||
Log.d("migrateGitRepo $fromGitBasePath $toGitBaseFolder");
|
||||
var fromBasePath = p.join(gitBasePath, fromGitBasePath);
|
||||
@ -40,8 +41,8 @@ Future migrateGitRepo({
|
||||
await gitRepo.add(fileName);
|
||||
await gitRepo.commit(
|
||||
message: "Added Note",
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: gitAuthorEmail,
|
||||
authorName: gitAuthor,
|
||||
);
|
||||
}
|
||||
Log.d("migrateGitRepo: Done");
|
||||
|
@ -25,9 +25,11 @@ class NoteRepoResult {
|
||||
class GitNoteRepository {
|
||||
final String gitDirPath;
|
||||
final GitRepo _gitRepo;
|
||||
final Settings settings;
|
||||
|
||||
GitNoteRepository({
|
||||
@required this.gitDirPath,
|
||||
@required this.settings,
|
||||
}) : _gitRepo = GitRepo(folderPath: gitDirPath);
|
||||
|
||||
Future<NoteRepoResult> addNote(Note note) async {
|
||||
@ -38,8 +40,8 @@ class GitNoteRepository {
|
||||
await _gitRepo.add(".");
|
||||
await _gitRepo.commit(
|
||||
message: commitMessage,
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: note.filePath, error: false);
|
||||
@ -49,8 +51,8 @@ class GitNoteRepository {
|
||||
await _gitRepo.add(".");
|
||||
await _gitRepo.commit(
|
||||
message: "Created New Folder",
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: folder.folderPath, error: false);
|
||||
@ -63,8 +65,8 @@ class GitNoteRepository {
|
||||
await _gitRepo.add(".");
|
||||
await _gitRepo.commit(
|
||||
message: "Update folder config for $pathSpec",
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: config.folder.folderPath, error: false);
|
||||
@ -78,8 +80,8 @@ class GitNoteRepository {
|
||||
await _gitRepo.add(".");
|
||||
await _gitRepo.commit(
|
||||
message: "Renamed Folder",
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: newFullPath, error: false);
|
||||
@ -93,8 +95,8 @@ class GitNoteRepository {
|
||||
await _gitRepo.add(".");
|
||||
await _gitRepo.commit(
|
||||
message: "Renamed Note",
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: newFullPath, error: false);
|
||||
@ -108,8 +110,8 @@ class GitNoteRepository {
|
||||
await _gitRepo.add(".");
|
||||
await _gitRepo.commit(
|
||||
message: "Renamed File",
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: newFullPath, error: false);
|
||||
@ -123,8 +125,8 @@ class GitNoteRepository {
|
||||
await _gitRepo.add(".");
|
||||
await _gitRepo.commit(
|
||||
message: "Note Moved",
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: newFullPath, error: false);
|
||||
@ -136,8 +138,8 @@ class GitNoteRepository {
|
||||
await _gitRepo.rm(spec);
|
||||
await _gitRepo.commit(
|
||||
message: "Removed Note " + spec,
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: note.filePath, error: false);
|
||||
@ -148,8 +150,8 @@ class GitNoteRepository {
|
||||
await _gitRepo.rm(spec);
|
||||
await _gitRepo.commit(
|
||||
message: "Removed Folder " + spec,
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
|
||||
await Directory(folder.folderPath).delete(recursive: true);
|
||||
@ -169,8 +171,8 @@ class GitNoteRepository {
|
||||
Future<void> pull() async {
|
||||
try {
|
||||
await _gitRepo.pull(
|
||||
authorEmail: Settings.instance.gitAuthorEmail,
|
||||
authorName: Settings.instance.gitAuthor,
|
||||
authorEmail: settings.gitAuthorEmail,
|
||||
authorName: settings.gitAuthor,
|
||||
);
|
||||
} on GitException catch (ex, stackTrace) {
|
||||
Log.e("GitPull Failed", ex: ex, stacktrace: stackTrace);
|
||||
|
@ -48,7 +48,7 @@ class StateContainer with ChangeNotifier {
|
||||
repoPath = p.join(gitBaseDirectory, settings.localGitRepoFolderName);
|
||||
}
|
||||
|
||||
_gitRepo = GitNoteRepository(gitDirPath: repoPath);
|
||||
_gitRepo = GitNoteRepository(gitDirPath: repoPath, settings: settings);
|
||||
appState.notesFolder = NotesFolderFS(null, _gitRepo.gitDirPath);
|
||||
|
||||
// Just a fail safe
|
||||
@ -361,11 +361,13 @@ class StateContainer with ChangeNotifier {
|
||||
fromGitBasePath: settings.localGitRepoFolderName,
|
||||
toGitBaseFolder: settings.remoteGitRepoFolderName,
|
||||
gitBasePath: gitBaseDirectory,
|
||||
gitAuthor: settings.gitAuthor,
|
||||
gitAuthorEmail: settings.gitAuthorEmail,
|
||||
);
|
||||
}
|
||||
|
||||
var repoPath = p.join(gitBaseDirectory, settings.remoteGitRepoFolderName);
|
||||
_gitRepo = GitNoteRepository(gitDirPath: repoPath);
|
||||
_gitRepo = GitNoteRepository(gitDirPath: repoPath, settings: settings);
|
||||
appState.notesFolder.reset(_gitRepo.gitDirPath);
|
||||
|
||||
await _persistConfig();
|
||||
|
Reference in New Issue
Block a user