Esempio n. 1
0
        private async Task ProcessEntryAsync(GitHubProjectInfo projectInfo, IGitHubClient githubClient, ChangeLogEntry entry)
        {
            m_Logger.LogDebug($"Adding links to entry {entry.Commit}");

            foreach (var footer in entry.Footers)
            {
                if (footer.Value is CommitReferenceTextElement commitReference)
                {
                    var uri = await TryGetWebUriAsync(githubClient, projectInfo, commitReference.CommitId);

                    if (uri is not null)
                    {
                        footer.Value = CommitReferenceTextElementWithWebLink.FromCommitReference(commitReference, uri);
                    }
                    else
                    {
                        m_Logger.LogWarning($"Failed to determine web uri for commit '{commitReference.CommitId}'");
                    }
                }
                else if (footer.Value is PlainTextElement && GitHubReference.TryParse(footer.Value.Text, projectInfo, out var reference))
                {
                    var uri = await TryGetWebUriAsync(githubClient, reference);

                    if (uri is not null)
                    {
                        footer.Value = new GitHubReferenceTextElement(footer.Value.Text, uri, projectInfo, reference);
                    }
                    else
                    {
                        m_Logger.LogWarning($"Failed to determine web uri for reference '{reference}'");
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of <see cref="GitHubReferenceTextElement"/>.
        /// </summary>
        public GitHubReferenceTextElement(string text, Uri uri, GitHubProjectInfo currentProject, GitHubReference reference)
        {
            if (String.IsNullOrWhiteSpace(text))
            {
                throw new ArgumentException("Value must not be null or whitespace", nameof(text));
            }

            Text           = text;
            Uri            = uri ?? throw new ArgumentNullException(nameof(uri));
            CurrentProject = currentProject ?? throw new ArgumentNullException(nameof(currentProject));
            Reference      = reference ?? throw new ArgumentNullException(nameof(reference));
        }
Esempio n. 3
0
        private async Task <Uri?> TryGetIssueWebUriAsync(IGitHubClient githubClient, GitHubReference reference)
        {
            try
            {
                var issue = await githubClient.Issue.Get(reference.Project.Owner, reference.Project.Repository, reference.Id);

                return(new Uri(issue.HtmlUrl));
            }
            catch (NotFoundException)
            {
                return(null);
            }
        }
Esempio n. 4
0
        private async Task <Uri?> TryGetWebUriAsync(IGitHubClient githubClient, GitHubReference reference)
        {
            m_Logger.LogDebug($"Getting web uri for reference '{reference}'");

            // check if the id is an issue
            var uri = await TryGetIssueWebUriAsync(githubClient, reference);

            // if it is not an issue, check if it is a Pull Request Id
            if (uri == null)
            {
                uri = await TryGetPullRequestWebUriAsync(githubClient, reference);
            }

            return(uri);
        }