Use dart-git's merge when cloning

This commit is contained in:
Vishesh Handa
2021-07-08 09:40:02 +02:00
parent 63c8f4a00a
commit 4e1df9bc31
3 changed files with 28 additions and 25 deletions

View File

@ -258,22 +258,13 @@ class GitNoteRepository {
Log.e("Failed to get remote refs", ex: r.error, stacktrace: r.stackTrace);
return fail(r);
}
var remoteBranchRef = r.getOrThrow();
if (useDartGit || AppSettings.instance.experimentalGitMerge) {
var hash = remoteBranchRef.hash!;
var commit = await repo.objStorage.read(hash).getOrThrow();
await repo
.merge(
theirCommit: commit as GitCommit,
author: GitAuthor(
email: settings.gitAuthorEmail,
name: settings.gitAuthor,
),
message: "Merging ...",
)
.throwOnError();
return Result(null);
var author = GitAuthor(
email: settings.gitAuthorEmail,
name: settings.gitAuthor,
);
return repo.mergeCurrentTrackingBranch(author: author);
}
try {

View File

@ -91,11 +91,17 @@ Future<Result<void>> cloneRemote({
var remoteBranchR = await repo.remoteBranch(remoteName, remoteBranchName);
if (remoteBranchR.isSuccess) {
Log.i("Merging '$remoteName/$remoteBranchName'");
await _gitRepo.merge(
branch: '$remoteName/$remoteBranchName',
authorName: authorName,
authorEmail: authorEmail,
);
if (Platform.isAndroid || Platform.isIOS) {
await _gitRepo.merge(
branch: '$remoteName/$remoteBranchName',
authorName: authorName,
authorEmail: authorEmail,
);
} else {
var repo = await GitRepository.load(repoPath).getOrThrow();
var author = GitAuthor(name: authorName, email: authorEmail);
repo.mergeCurrentTrackingBranch(author: author).throwOnError();
}
}
} else {
Log.i("Completing - localBranch diff remote: $branch $remoteBranchName");
@ -106,11 +112,17 @@ Future<Result<void>> cloneRemote({
await repo.setUpstreamTo(remote, remoteBranchName).getOrThrow();
Log.i("Merging '$remoteName/$remoteBranchName'");
await _gitRepo.merge(
branch: '$remoteName/$remoteBranchName',
authorName: authorName,
authorEmail: authorEmail,
);
if (Platform.isAndroid || Platform.isIOS) {
await _gitRepo.merge(
branch: '$remoteName/$remoteBranchName',
authorName: authorName,
authorEmail: authorEmail,
);
} else {
var repo = await GitRepository.load(repoPath).getOrThrow();
var author = GitAuthor(name: authorName, email: authorEmail);
repo.mergeCurrentTrackingBranch(author: author).throwOnError();
}
}
}

View File

@ -244,7 +244,7 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: b9d57da376b1d3156c306a835e64c9a98d759a4d
resolved-ref: "85eb017910093d10610159f984ffcfdc42bf4e83"
url: "https://github.com/GitJournal/dart-git.git"
source: git
version: "0.0.2"