Пример #1
0
        protected override async Task OnExecuteAsync(CommandLineApplication application)
        {
            string projectId                = HttpUtility.UrlEncode(Repository);
            string environmentHost          = Environment.GetEnvironmentVariable(Constant.EnvironmentHost);
            string environmentToken         = Environment.GetEnvironmentVariable(Constant.EnvironmentToken);
            var    gitlabApi                = new GitlabApi(Host ?? environmentHost, Token ?? environmentToken, projectId);
            var    labelDifferenceProcessor = new LabelDifferenceProcessor(gitlabApi);

            IReadOnlyList <Label> repositoryLabels = await gitlabApi.GetLabelsAsync();

            IReadOnlyList <Label> configuredLabels = readLabels();
            IReadOnlyList <LabelChangeStrategy> labelChangeStrategies = labelDifferenceProcessor.Process(repositoryLabels, configuredLabels);

            Console.WriteLine($"{projectId} label will be:");

            foreach (var labelChangeStrategy in labelChangeStrategies)
            {
                Console.WriteLine(labelChangeStrategy.ToString());
            }

            if (IsDryRun is false)
            {
                foreach (var labelChangeStrategy in labelChangeStrategies)
                {
                    await labelChangeStrategy.ChangeLabelAsync();
                }
            }
            else
            {
                Console.WriteLine("Dry Run: Not apply to Gitlab.");
            }
        }
Пример #2
0
        protected override async Task OnExecuteAsync(CommandLineApplication application)
        {
            string projectId        = HttpUtility.UrlEncode(Repository);
            string environmentHost  = Environment.GetEnvironmentVariable(Constant.EnvironmentHost);
            string environmentToken = Environment.GetEnvironmentVariable(Constant.EnvironmentToken);
            var    gitlabApi        = new GitlabApi(Host ?? environmentHost, Token ?? environmentToken, projectId);

            IReadOnlyList <Label> labels = await gitlabApi.GetLabelsAsync();

            Console.WriteLine($"{projectId} label are:");

            foreach (var label in labels)
            {
                Console.WriteLine(label.ToString());
            }

            if (OutputFileName is { })