public async Task MergeBranchCommitAsync(Commit commit) { using (statusService.PauseStatusNotifications()) { if (commit.Branch == commit.Repository.CurrentBranch) { message.ShowWarning("You cannot merge current branch into it self."); return; } if (commit.Repository.Status.Conflicted > 0 || commit.Repository.Status.AllChanges > 0) { message.ShowInfo("You must first commit uncommitted changes before merging."); return; } Branch currentBranch = commit.Repository.CurrentBranch; using (progress.ShowDialog($"Merging branch commit {commit.RealCommitSha.ShortSha} into {currentBranch.Name} ...")) { await gitMergeService.MergeAsync(commit.RealCommitSha.Sha, CancellationToken.None); repositoryCommands.SetCurrentMerging(commit.Branch, commit.RealCommitSha); await repositoryService.Value.CheckLocalRepositoryAsync(); } GitStatus status = repositoryService.Value.Repository.Status; if (status.Conflicted == 0) { await commitsService.CommitChangesAsync($"Merge branch '{commit.Branch.Name}'"); } else { repositoryCommands.ShowUncommittedDetails(); } } }
private async Task <R> MergeCurrentBranchAsync() { R <bool> ffResult = await gitMergeService.TryMergeFastForwardAsync(null, CancellationToken.None); if (ffResult.IsFaulted) { return(R.Error("Failed to merge current branch", ffResult.Exception)); } if (!ffResult.Value) { R result = await gitMergeService.MergeAsync(null, CancellationToken.None); if (result.IsFaulted) { return(R.Error("Failed to merge current branch", ffResult.Exception)); } } return(R.Ok); }