mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-25 16:19:58 +08:00
Sync: Allow the merge to fail
This commit is contained in:
@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:dart_git/config.dart';
|
import 'package:dart_git/config.dart';
|
||||||
import 'package:dart_git/dart_git.dart';
|
import 'package:dart_git/dart_git.dart';
|
||||||
|
import 'package:dart_git/exceptions.dart';
|
||||||
import 'package:git_bindings/git_bindings.dart';
|
import 'package:git_bindings/git_bindings.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
@ -176,7 +177,15 @@ class GitJournalRepo with ChangeNotifier {
|
|||||||
Future? noteLoadingFuture;
|
Future? noteLoadingFuture;
|
||||||
try {
|
try {
|
||||||
await _gitRepo.fetch().throwOnError();
|
await _gitRepo.fetch().throwOnError();
|
||||||
await _gitRepo.merge().throwOnError();
|
|
||||||
|
var r = await _gitRepo.merge();
|
||||||
|
if (r.isFailure) {
|
||||||
|
var ex = r.error!;
|
||||||
|
// When there is nothing to merge into
|
||||||
|
if (ex is! GitRefNotFound) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
syncStatus = SyncStatus.Pushing;
|
syncStatus = SyncStatus.Pushing;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -104,6 +104,7 @@ Future<Result<void>> cloneRemotePluggable({
|
|||||||
var remoteBranchName = branchNameR.getOrThrow();
|
var remoteBranchName = branchNameR.getOrThrow();
|
||||||
|
|
||||||
Log.i("Using remote branch: $remoteBranchName");
|
Log.i("Using remote branch: $remoteBranchName");
|
||||||
|
var skipCheckout = false;
|
||||||
|
|
||||||
var branches = await repo.branches().getOrThrow();
|
var branches = await repo.branches().getOrThrow();
|
||||||
if (branches.isEmpty) {
|
if (branches.isEmpty) {
|
||||||
@ -115,6 +116,7 @@ Future<Result<void>> cloneRemotePluggable({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remoteBranch doesn't exist - do nothing? Are you sure?
|
// remoteBranch doesn't exist - do nothing? Are you sure?
|
||||||
|
skipCheckout = true;
|
||||||
} else {
|
} else {
|
||||||
// remote branch exists
|
// remote branch exists
|
||||||
var remoteBranch = remoteBranchR.getOrThrow();
|
var remoteBranch = remoteBranchR.getOrThrow();
|
||||||
@ -172,10 +174,12 @@ Future<Result<void>> cloneRemotePluggable({
|
|||||||
// - Pack files are read into memory, this causes OOM issues
|
// - Pack files are read into memory, this causes OOM issues
|
||||||
// https://sentry.io/organizations/gitjournal/issues/2254310735/?project=5168082&query=is%3Aunresolved
|
// https://sentry.io/organizations/gitjournal/issues/2254310735/?project=5168082&query=is%3Aunresolved
|
||||||
//
|
//
|
||||||
|
if (!skipCheckout) {
|
||||||
var r = await repo.checkout(".");
|
var r = await repo.checkout(".");
|
||||||
if (r.isFailure) {
|
if (r.isFailure) {
|
||||||
return fail(r);
|
return fail(r);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Result(null);
|
return Result(null);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user