Exemple #1
0
        public static void SendMessage(GithubPullRequestComment comment)
        {
            var webhookUrl = Consts.SLACK_HOOK_URL;
            var client     = new SbmClient(webhookUrl);

            var message = new Message($"<!here> <{comment.Comment.User.HtmlUrl}|{comment.Comment.User.Login}> commented on <{comment.PullRequest.HtmlUrl}|{comment.PullRequest.Title}>");

            message.AddAttachment(new Attachment()
                                  .SetPretext($">{comment.Comment.Body}\n\n```{comment.Comment.DiffHunk}```")
                                  .SetFooter(comment.Comment.Path, comment.Comment.User.AvatarUrl.ToString(), comment.Comment.CreatedAt.UtcDateTime)
                                  );


            client.Send(message);
        }
        public GithubPullRequestComment GetFirstTeamComment(OurUmbraco.Community.Models.Repository repository, string pullRequestNumber)
        {
            GithubPullRequestComment firstTeamCommment = null;
            var pr = GetPullRequest(repository, pullRequestNumber);

            if (pr != null)
            {
                var users        = GetTeam(repository.Slug).Members.Select(x => x.ToLower());
                var foundComment = pr.Comments.OrderBy(x => x.created_at).FirstOrDefault(x => users.Contains(x.user.Login.ToLower()));
                if (foundComment != null)
                {
                    firstTeamCommment = foundComment;
                }
            }

            return(firstTeamCommment);
        }
Exemple #3
0
 public static string ToJson(this GithubPullRequestComment self) => JsonConvert.SerializeObject(self, Converter.Settings);