Ejemplo n.º 1
0
        private string ComposeBody(TransferObjects.Issue issue, List <string> issueAssignees)
        {
            var body = issue.Description;

            body += $"{Environment.NewLine}{Environment.NewLine}";
            body += $"**Imported from GitLab**{Environment.NewLine}";
            body += $"Created from {_userMapper.MapToGitHubUserName(issue.AuthorUserName)} at {issue.CreatedAt:u}{Environment.NewLine}";
            if (issueAssignees.Any())
            {
                body += $"Assigned to {string.Join(", ", issueAssignees)}{Environment.NewLine}";
            }

            body += $"{Environment.NewLine}*Issue History:*{Environment.NewLine}";
            foreach (var comment in issue.Comments.Where(c => c.System).OrderBy(c => c.Id))
            {
                body += $"* {comment.AuthorName} @{comment.AuthorUsername} {comment.Body} at {comment.CreatedDate:u}{Environment.NewLine}";
            }
            return(body);
        }
Ejemplo n.º 2
0
        public async Task <ICollection <TransferObjects.Issue> > GetIssues(Project project)
        {
            var issues = new List <TransferObjects.Issue>();

            var gitlabIssues = await _gitLabClient.Issues.GetAsync(project.Id.ToString(), o => o.State = IssueState.All);

            foreach (var gitlabIssue in gitlabIssues)
            {
                var issue = new TransferObjects.Issue
                {
                    Id             = gitlabIssue.Id,
                    Title          = gitlabIssue.Title,
                    Description    = gitlabIssue.Description,
                    AuthorUserName = gitlabIssue.Author.Username,
                    CreatedAt      = gitlabIssue.CreatedAt,
                    MilestoneId    = gitlabIssue.Milestone?.Id,
                    Closed         = gitlabIssue.State == IssueState.Closed,
                };
                gitlabIssue.Labels.ForEach(issue.Labels.Add);
                gitlabIssue.Assignees.ForEach(a => issue.AssigneeUserNames.Add(a.Username));

                var issueNotes = await _gitLabClient.Issues.GetNotesAsync(project.Id, gitlabIssue.Iid);

                foreach (var issueNote in issueNotes)
                {
                    issue.Comments.Add(new TransferObjects.Comment
                    {
                        Id             = issueNote.Id,
                        CreatedDate    = issueNote.CreatedAt,
                        AuthorName     = issueNote.Author.Name,
                        AuthorUsername = issueNote.Author.Username,
                        Body           = issueNote.Body,
                        System         = issueNote.System
                    });
                }

                issues.Add(issue);
            }

            return(issues);
        }