示例#1
0
        /// <summary>
        /// Конструктор по умолчанию
        /// </summary>
        /// <param name="gitlabProject">Проект в GitLab</param>
        /// <param name="remoteBranchProvider">Провайдер удаленных ветвей</param>
        /// <param name="branchInfoProvider">Провайдер информации о ветвях</param>
        public GitlabDefaultBranchProvider(
            Holder <Project> gitlabProject,
            IRemoteBranchProvider remoteBranchProvider,
            IBranchInfoProvider branchInfoProvider)
        {
            ValueGetter = () =>
            {
                var project = gitlabProject.Value;

                var defaultBranchInfo = project == null
                    ? BranchInfo.Develop
                    : branchInfoProvider.GetBranchInfo(project.DefaultBranch);

                return(new DefaultBranchInfo(defaultBranchInfo, remoteBranchProvider));
            };
        }
        /// <summary>
        /// Конктруктор по умолчанию для типа <see cref="BranchInfoProvider"/>
        /// </summary>
        /// <param name="configuration">Конфигурация системы</param>
        /// <param name="mergeRequsts">Клиент запросов на слияние в системе GitLab</param>
        /// <param name="branchInfoProvider">Провайдер информации о конкретной ветви</param>
        public BranchInfoProvider(
            ConfigurationHolder configuration,
            Holder <IMergeRequestClient> mergeRequsts,
            IBranchInfoProvider branchInfoProvider)
        {
            ValueGetter = () =>
            {
                var labels = new HashSet <string>(configuration.Array("GitLab", "PickedLabels"));

                var pickedMergeRequests = mergeRequsts.Value
                                          .AllInState(MergeRequestState.opened)
                                          .Where(x => x.Labels.Any(labels.Contains));

                var branches = pickedMergeRequests
                               .Select(x => branchInfoProvider
                                       .GetBranchInfo(x.SourceBranch)
                                       .SetTag(x.Labels))
                               .OrderBy(x => x.Id);

                return(branches.ToList());
            };
        }