Example #1
0
        public async Task OnGet(int channelId, string owner, string repo)
        {
            var repoUrl = $"https://github.com/{owner}/{repo}";
            var latest  = await _client.GetLatestAsync(repoUrl, null, null, channelId, null, null, false, ApiVersion10._20190116);

            var graph = await _client.GetBuildGraphAsync(latest.Id, (ApiVersion9)ApiVersion40._20190116);

            latest = graph.Builds[latest.Id.ToString()];

            var incoming = new List <IncomingRepo>();

            foreach (var dep in latest.Dependencies)
            {
                var build = graph.Builds[dep.BuildId.ToString()];

                GitHubInfo?gitHubInfo = null;
                if (!string.IsNullOrEmpty(build.GitHubRepository))
                {
                    var match = _repoParser.Match(build.GitHubRepository);
                    if (match.Success)
                    {
                        gitHubInfo = new GitHubInfo(
                            match.Groups["owner"].Value,
                            match.Groups["repo"].Value);
                    }
                }

                if (!IncludeRepo(gitHubInfo))
                {
                    continue;
                }

                var(commitDistance, commitAge) = await GetCommitInfo(gitHubInfo, build);

                incoming.Add(new IncomingRepo(
                                 build,
                                 shortName: gitHubInfo?.Repo ?? "",
                                 commitDistance,
                                 GetCommitUrl(build),
                                 buildUrl: $"https://dev.azure.com/{build.AzureDevOpsAccount}/{build.AzureDevOpsProject}/_build/results?buildId={build.AzureDevOpsBuildId}&view=results",
                                 commitAge
                                 ));
            }
            IncomingRepositories = incoming;

            CurrentRateLimit = _github.GetLastApiInfo().RateLimit;
        }
        public async Task OnGet(int channelId, string owner, string repo)
        {
            var channel = await _client.GetChannelAsync(channelId, ApiVersion13._20190116);

            ChannelName = channel.Name;

            var repoUrl = $"https://github.com/{owner}/{repo}";
            var latest  = await _client.GetLatestAsync(repoUrl, null, null, channelId, null, null, false, ApiVersion10._20190116, CancellationToken.None);

            var graph = await _client.GetBuildGraphAsync(latest.Id, (ApiVersion9)ApiVersion40._20190116, CancellationToken.None);

            Build = graph.Builds[latest.Id.ToString()];

            var incoming = new List <IncomingRepo>();

            foreach (var dep in Build.Dependencies)
            {
                var lastConsumedBuildOfDependency = graph.Builds[dep.BuildId.ToString()];

                var gitHubInfo = GetGitHubInfo(lastConsumedBuildOfDependency);

                if (!IncludeRepo(gitHubInfo))
                {
                    continue;
                }

                var(commitDistance, commitAge) = await GetCommitInfo(gitHubInfo, lastConsumedBuildOfDependency);

                var oldestPublishedButUnconsumedBuild = await GetOldestUnconsumedBuild(lastConsumedBuildOfDependency.Id);

                incoming.Add(new IncomingRepo(
                                 lastConsumedBuildOfDependency,
                                 shortName: gitHubInfo?.Repo ?? "",
                                 oldestPublishedButUnconsumedBuild,
                                 GetCommitUrl(lastConsumedBuildOfDependency),
                                 GetBuildUrl(lastConsumedBuildOfDependency),
                                 commitDistance,
                                 commitAge));
            }
            IncomingRepositories = incoming;

            CurrentRateLimit = _github.GetLastApiInfo().RateLimit;
        }
        public async Task OnGet(int channelId, string owner, string repo)
        {
            var repoUrl = $"https://github.com/{owner}/{repo}";
            var latest  = await _client.GetLatestAsync(repoUrl, null, null, channelId, null, null, false, ApiVersion10._20190116);

            var graph = await _client.GetBuildGraphAsync(latest.Id, (ApiVersion9)ApiVersion40._20190116);

            Build = graph.Builds[latest.Id.ToString()];

            var incoming = new List <IncomingRepo>();

            foreach (var dep in Build.Dependencies)
            {
                var build = graph.Builds[dep.BuildId.ToString()];

                var gitHubInfo = GetGitHubInfo(build);

                if (!IncludeRepo(gitHubInfo))
                {
                    continue;
                }

                var(commitDistance, commitAge) = await GetCommitInfo(gitHubInfo, build);

                incoming.Add(new IncomingRepo(
                                 build,
                                 shortName: gitHubInfo?.Repo ?? "",
                                 commitDistance,
                                 GetCommitUrl(build),
                                 buildUrl: GetBuildUrl(build),
                                 commitAge
                                 ));
            }
            IncomingRepositories = incoming;

            CurrentRateLimit = _github.GetLastApiInfo().RateLimit;
        }