Improve repo migrations

Earlier we had one folder 'journal_local', when the remote would be
setup a new folder called 'journal' would be created, and each all the
files would be copied over. This meant the local history was being
destroyed.

Now, we only have 1 folder 'journal', and on 'cloning', we add the url
as a remote, and do a git fetch + merge.

This simplifies everything drastically, and opens the door for multiple
remotes.
This commit is contained in:
Vishesh Handa
2020-10-15 12:07:35 +02:00
parent 0839b8e38a
commit 540078c413
8 changed files with 93 additions and 139 deletions

View File

@ -180,14 +180,18 @@ class GitNoteRepository {
Future<void> merge() async {
var repo = await git.GitRepository.load(gitDirPath);
var branch = await repo.currentBranch();
if (branch == null) {
var branchConfig = repo.config.branch(branch);
if (branchConfig == null) {
logExceptionWarning(Exception("Current Branch null"), StackTrace.current);
return;
}
assert(branchConfig.name != null);
assert(branchConfig.merge != null);
try {
await _gitRepo.merge(
branch: branch.remoteTrackingBranch(),
branch: branchConfig.remoteTrackingBranch(),
authorEmail: settings.gitAuthorEmail,
authorName: settings.gitAuthor,
);