From 66eeaa552b7d1853ee8483790be62e8e98aeef6e Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Wed, 13 May 2020 11:35:14 +0200 Subject: [PATCH] Bump git_bindings and pass fresh version of gitAuthor/Email This way the Settings change for git author is immediately reflected. Fixes #130 --- lib/apis/git_migration.dart | 8 ++++---- lib/core/git_repo.dart | 27 +++++++++++++++++++++------ lib/setup/screens.dart | 8 +++++--- pubspec.lock | 2 +- pubspec.yaml | 2 +- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/lib/apis/git_migration.dart b/lib/apis/git_migration.dart index 3a8ebe48..188cd4a5 100644 --- a/lib/apis/git_migration.dart +++ b/lib/apis/git_migration.dart @@ -35,13 +35,13 @@ Future migrateGitRepo({ await file.copy(toPath); - var gitRepo = GitRepo( - folderPath: toGitRepoPath, + var gitRepo = GitRepo(folderPath: toGitRepoPath); + await gitRepo.add(fileName); + await gitRepo.commit( + message: "Added Note", authorEmail: Settings.instance.gitAuthorEmail, authorName: Settings.instance.gitAuthor, ); - await gitRepo.add(fileName); - await gitRepo.commit(message: "Added Note"); } Log.d("migrateGitRepo: Done"); } diff --git a/lib/core/git_repo.dart b/lib/core/git_repo.dart index b64fe8a5..ae2779c7 100644 --- a/lib/core/git_repo.dart +++ b/lib/core/git_repo.dart @@ -29,11 +29,7 @@ class GitNoteRepository { GitNoteRepository({ @required this.gitDirPath, - }) : _gitRepo = GitRepo( - folderPath: gitDirPath, - authorEmail: Settings.instance.gitAuthorEmail, - authorName: Settings.instance.gitAuthor, - ); + }) : _gitRepo = GitRepo(folderPath: gitDirPath); Future addNote(Note note) async { return _addNote(note, "Added Note"); @@ -44,6 +40,8 @@ class GitNoteRepository { await _gitRepo.add("."); await _gitRepo.commit( message: commitMessage, + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, ); return NoteRepoResult(noteFilePath: note.filePath, error: false); @@ -53,6 +51,8 @@ class GitNoteRepository { await _gitRepo.add("."); await _gitRepo.commit( message: "Created New Folder", + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, ); return NoteRepoResult(noteFilePath: folder.folderPath, error: false); @@ -65,6 +65,8 @@ class GitNoteRepository { await _gitRepo.add("."); await _gitRepo.commit( message: "Update folder config for $pathSpec", + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, ); return NoteRepoResult(noteFilePath: config.folder.folderPath, error: false); @@ -78,6 +80,8 @@ class GitNoteRepository { await _gitRepo.add("."); await _gitRepo.commit( message: "Renamed Folder", + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, ); return NoteRepoResult(noteFilePath: newFullPath, error: false); @@ -91,6 +95,8 @@ class GitNoteRepository { await _gitRepo.add("."); await _gitRepo.commit( message: "Renamed Note", + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, ); return NoteRepoResult(noteFilePath: newFullPath, error: false); @@ -104,6 +110,8 @@ class GitNoteRepository { await _gitRepo.add("."); await _gitRepo.commit( message: "Note Moved", + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, ); return NoteRepoResult(noteFilePath: newFullPath, error: false); @@ -115,6 +123,8 @@ class GitNoteRepository { await _gitRepo.rm(spec); await _gitRepo.commit( message: "Removed Note " + spec, + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, ); return NoteRepoResult(noteFilePath: note.filePath, error: false); @@ -125,6 +135,8 @@ class GitNoteRepository { await _gitRepo.rm(spec); await _gitRepo.commit( message: "Removed Folder " + spec, + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, ); await Directory(folder.folderPath).delete(recursive: true); @@ -143,7 +155,10 @@ class GitNoteRepository { Future pull() async { try { - await _gitRepo.pull(); + await _gitRepo.pull( + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, + ); } on GitException catch (ex) { Log.d(ex.toString()); } diff --git a/lib/setup/screens.dart b/lib/setup/screens.dart index 255246d6..f7afdedd 100644 --- a/lib/setup/screens.dart +++ b/lib/setup/screens.dart @@ -477,11 +477,13 @@ class GitHostSetupScreenState extends State { var repo = GitRepo( folderPath: repoPath, - authorName: Settings.instance.gitAuthor, - authorEmail: Settings.instance.gitAuthorEmail, ); await repo.add('.gitignore'); - await repo.commit(message: "Add gitignore file"); + await repo.commit( + message: "Add gitignore file", + authorEmail: Settings.instance.gitAuthorEmail, + authorName: Settings.instance.gitAuthor, + ); } getAnalytics().logEvent( diff --git a/pubspec.lock b/pubspec.lock index 2b80582b..4cfe43b8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -356,7 +356,7 @@ packages: name: git_bindings url: "https://pub.dartlang.org" source: hosted - version: "0.0.12" + version: "0.0.13" git_url_parse2: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 6ac6f2da..5f6d78da 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,7 +30,7 @@ dependencies: dynamic_theme: ^1.0.0 flutter_staggered_grid_view: ^0.3.0 provider: ^3.2.0 - git_bindings: ^0.0.12 + git_bindings: ^0.0.13 dart_git: git: https://github.com/GitJournal/dart_git.git #path: /Users/vishesh/src/gitjournal/dart_git