Example #1
0
        private async Task DoGetLatestOnBranchAsync(WorkspaceModel workspaceModel, string sourceBranch, string targetBranch)
        {
            var latestVersionForBranches = (Branch)_configHelper.GetValue <int>(ConfigKeys.LATEST_VERSION_FOR_BRANCH);

            if (latestVersionForBranches != Branch.None)
            {
                SetCurrentAction(string.Format(CultureInfo.CurrentUICulture, Resources.GettingLatestVersionForBranch, latestVersionForBranches.GetDescription()));
                var branchNamesForLatestVersion = GetBranchesForExecutingGetLatest(latestVersionForBranches, sourceBranch, targetBranch);

                var hasConflicts = await _mergeService.GetLatestVersion(workspaceModel, branchNamesForLatestVersion.ToArray());

                if (hasConflicts)
                {
                    var shouldResolveConflicts = _configHelper.GetValue <bool>(ConfigKeys.SHOULD_RESOLVE_CONFLICTS);

                    if (shouldResolveConflicts)
                    {
                        await _mergeService.ResolveConflicts(workspaceModel);

                        if (_mergeService.HasConflicts(workspaceModel))
                        {
                            throw new MergeActionException(Resources.GetLatestConflicts);
                        }
                    }
                    else
                    {
                        throw new MergeActionException(Resources.GetLatestConflicts);
                    }
                }
            }
        }