Exemplo n.º 1
0
        protected override async Task OnExecuteAsync(CommandLineApplication application)
        {
            (string owner, string repositoryName) = parseRepository();
            string environmentHost          = Environment.GetEnvironmentVariable(Constant.EnvironmentHost);
            string environmentToken         = Environment.GetEnvironmentVariable(Constant.EnvironmentToken);
            var    githubApi                = new GithubApi(Host ?? environmentHost, Token ?? environmentToken, owner, repositoryName);
            var    labelDifferenceProcessor = new LabelDifferenceProcessor(githubApi);

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

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

            Console.WriteLine($"{owner}/{repositoryName} 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 Github.");
            }
        }
Exemplo n.º 2
0
        protected override async Task OnExecuteAsync(CommandLineApplication application)
        {
            (string owner, string repositoryName) = parseRepository();
            string environmentHost  = Environment.GetEnvironmentVariable(Constant.EnvironmentHost);
            string environmentToken = Environment.GetEnvironmentVariable(Constant.EnvironmentToken);
            var    githubApi        = new GithubApi(Host ?? environmentHost, Token ?? environmentToken, owner, repositoryName);

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

            Console.WriteLine($"{owner}/{repositoryName} label are:");

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

            if (OutputFileName is { })