private string FormatAction(TextElement text)
 {
     switch (Status)
         {
             case PullRequestStatus.Abandoned: return text.Abandoned;
             case PullRequestStatus.Active: return text.Reactivated;
             case PullRequestStatus.Completed: return text.Completed;
             default:
                 return $"updated status to {Status} for";
         }
 }
        public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                ProjectUrl,
                ProjectName = transform(ProjectName),
            };

            return new[] { text.ProjectCreatedFormat.FormatWith(formatter) };
        }
 private string FormatAction(TextElement text)
 {
     switch (Vote)
     {
         case -10: return text.VoteRejected;
         case 0: return text.VoteRescinded;
         case 10: return text.VoteApproved;
         default:
             return $"voted {Vote} on";
     }
 }
Beispiel #4
0
 public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
 {
     var formatter = new
     {
         DisplayName = transform(DisplayName), RepoUri,
         ProjectName = transform(ProjectName),
         RepoName = transform(RepoName),
         Pushed = IsForcePush ? text.ForcePushed : text.Pushed,
         UserName = transform(UserName),
         MappedUser = bot.GetMappedUser(UniqueName)
     };
     return text.PushFormat.FormatWith(formatter);
 }
        public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                UserName = transform(UserName),
                ProjectName = transform(ProjectName),
                ProjectUrl,
                RepoUri,
                RepoName = transform(RepoName),
                MappedUser = bot.GetMappedUser(UniqueName)
            };

            return new[] { GetFormat(text).FormatWith(formatter) };
        }
 public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
 {
     var formatter = new
     {
         TeamProjectCollection = transform(TeamProjectCollection),
         ProjectName = transform(ProjectName),
         ReleaseDefinition = transform(ReleaseDefinition),
         ReleaseStatus = transform(ReleaseStatus.ToString()),
         ReleaseUrl,
         ReleaseName = transform(ReleaseName),
         ReleaseReason = transform(ReleaseReason.ToString()),
         CreatedBy = transform(CreatedByUniqueName),
         CreatedByDisplayName = transform(CreatedByDisplayName),
         DisplayName = transform(CreatedByDisplayName),
         CreatedOn,
         UserName = transform(UserName),
         MappedUser = bot.GetMappedUser(CreatedByUniqueName)
     };
     return new[] { text.ReleaseCreatedFormat.FormatWith(formatter) };
 }
        public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                ProjectName = transform(ProjectName),
                RepoUri,
                RepoName = transform(RepoName),
                PrId,
                PrUrl,
                PrTitle = transform(PrTitle),
                UserName = transform(UserName),
                SourceBranchName = transform(SourceBranch.Name),
                TargetBranchName = transform(TargetBranch.Name),
                MappedUser = bot.GetMappedUser(UniqueName)
            };

            return new[] { text.PullRequestCreatedFormat.FormatWith(formatter) };
        }
 public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
 {
     var formatter = new
     {
         TeamProjectCollection = transform(TeamProjectCollection),
         ProjectName = transform(ProjectName),
         BuildDefinition = transform(BuildDefinition),
         BuildStatus = transform(BuildStatus.ToString()), BuildUrl,
         BuildNumber = transform(BuildNumber),
         BuildReason = transform(BuildReason.ToString()),
         RequestedFor = transform(RequestedForUniqueName),
         RequestedForDisplayName = transform(RequestedForDisplayName),
         DisplayName = transform(RequestedForDisplayName),
         StartTime,
         FinishTime,
         UserName = transform(UserName),
         BuildDuration = FormatBuildDuration(text),
         DropLocation,
         NewValue = NewValue == null ? text.BuildQualityNotSet : transform(NewValue),
         OldValue = OldValue == null ? text.BuildQualityNotSet : transform(OldValue),
     };
     return new[] { text.BuildQualityChangedFormat.FormatWith(formatter) };
 }
        public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
        {
            var lines = new List<string>();
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                ProjectName = transform(ProjectName),
                AreaPath = transform(AreaPath),
                WiUrl,
                WiType = transform(WiType),
                WiId,
                WiTitle = transform(WiTitle),
                UserName = transform(UserName),
                Action = text.CommentedOn,
                AssignedToUserName = transform(AssignedToUserName),
                MappedAssignedToUser = bot.GetMappedUser(AssignedToUniqueName),
                MappedUser = bot.GetMappedUser(UniqueName)
            };
            lines.Add(text.WorkItemchangedFormat.FormatWith(formatter));
            lines.Add(TextHelper.Truncate(Comment, Settings.DiscussionCommentMaxLength));

            return lines;
        }
Beispiel #10
0
 public static string ToString(this IEnumerable<GitRef> refs, TextElement text, Func<string, string> transform)
 {
     return string.Join(text.RefSeparator, refs.Select(r => r.ToString(text, transform)));
 }
 public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
 {
     var formatter = new
     {
         TeamProjectCollection = transform(TeamProjectCollection),
         DisplayName = transform(DisplayName),
         ChangesetUrl,
         ChangesetId,
         Comment = transform(Comment),
         UserName = transform(UserName),
         ProjectLinks = FormatProjectLinks(text, transform),
         MappedUser = bot.GetMappedUser(UniqueName)
     };
     return new[] { text.CheckinFormat.FormatWith(formatter) };
 }
Beispiel #12
0
        public string ToString(TextElement text, Func<string, string> transform)
        {
            string pattern = Type == GitRefType.Tag ? text.TagFormat : text.BranchFormat;
            var sb = new StringBuilder();
            if (Type == GitRefType.Branch && IsNew) sb.Append("+");
            sb.Append(Name);

            return pattern.FormatWith(new
            {
                Name = transform(sb.ToString())
            });
        }
 protected override string GetBuildFormat(TextElement text)
 {
     return string.IsNullOrEmpty(text.Build2015Format) ? text.BuildFormat : text.Build2015Format;
 }
 private string FormatProjectLinks(TextElement text, Func<string, string> transform)
 {
     return string.Join(", ", Projects.Select(x => text.ProjectLinkFormat
         .FormatWith(new { ProjectName = transform(x.Key), ProjectUrl = x.Value })));
 }
Beispiel #15
0
        public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
        {
            string formattedTime = string.IsNullOrEmpty(text.DateTimeFormat) ? AuthorTime.ToString() : AuthorTime.ToString(text.DateTimeFormat);
            var sb = new StringBuilder();
            if (Refs != null) sb.AppendFormat("{0} ", Refs.ToString(text, transform));

            sb.Append(text.CommitFormat.FormatWith(new
            {
                Action = Type == CommitRowType.Commit ? text.Commit : text.RefPointer, CommitUri,
                CommitId = transform(CommitId.ToHexString(Settings.HashLength)),
                ChangeCounts = (ChangeCounts != null) ? ChangeCountsToString(text, ChangeCounts) : "",
                AuthorTime = formattedTime,
                Author = transform(Author),
                AuthorName = transform(AuthorName),
                AuthorEmail = transform(AuthorEmail),
                Comment = transform(Comment.Truncate(Settings.CommentMaxLength, true))
            }));

            return sb.ToString();
        }
Beispiel #16
0
        private string ChangeCountsToString(TextElement text, Dictionary<TfsGitChangeType, int> changeCounts)
        {
            var counters = new[] {
                new ChangeCounter(TfsGitChangeType.Add, text.ChangeCountAddFormat, 0),
                new ChangeCounter(TfsGitChangeType.Edit, text.ChangeCountEditFormat, 0),
                new ChangeCounter(TfsGitChangeType.Delete, text.ChangeCountDeleteFormat, 0),
                new ChangeCounter(TfsGitChangeType.Rename, text.ChangeCountRenameFormat, 0),
                new ChangeCounter(TfsGitChangeType.SourceRename, text.ChangeCountSourceRenameFormat, 0)
            };

            foreach (var changeCount in changeCounts)
            {
                // renamed files will also show up as Rename or Rename+Edit, so don't count them twice
                if (changeCount.Key == (TfsGitChangeType.Delete | TfsGitChangeType.SourceRename)) continue;

                foreach (var counter in counters.Where(c => changeCount.Key.HasFlag(c.Type)))
                {
                    counter.Count += changeCount.Value;
                }
            }

            return string.Join(", ", counters.Where(c => c.Count > 0).Select(c => c.Format.FormatWith(new {c.Count })));
        }
 public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
 {
     var formatter = new
     {
         TeamProjectCollection = transform(TeamProjectCollection),
         ProjectName = transform(ProjectName),
         BuildDefinition = transform(BuildDefinition),
         BuildStatus = transform(BuildStatus.ToString()),
         BuildUrl,
         BuildNumber = transform(BuildNumber),
         BuildReason = transform(BuildReason.ToString()),
         RequestedFor = transform(RequestedForUniqueName),
         RequestedForDisplayName = transform(RequestedForDisplayName),
         DisplayName = transform(RequestedForDisplayName),
         StartTime,
         FinishTime,
         UserName = transform(UserName),
         BuildDuration = FormatBuildDuration(text),
         DropLocation,
         MappedUser = bot.GetMappedUser(RequestedForUniqueName)
     };
     return new[] { GetBuildFormat(text).FormatWith(formatter), transform(BuildStatus.ToString()) };
 }
 private string FormatAction(TextElement text)
 {
     return IsNew ? text.Created : text.Updated;
 }
 protected abstract string GetFormat(TextElement text);
 public abstract string ToString(BotElement bot, TextElement text, Func<string, string> transform);
 protected string FormatBuildDuration(TextElement text)
 {
     var duration = FinishTime - StartTime;
     return string.IsNullOrEmpty(text.TimeSpanFormat) ? duration.ToString(@"hh\:mm\:ss") : duration.ToString(text.TimeSpanFormat);
 }
Beispiel #22
0
 public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
 {
     return transform(Text);
 }
 public abstract IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform);
 public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
 {
     return String.Format("{0} {1} {2} {3}", Refs.ToString(text, transform), text.RefPointer, transform(ObjectType.ToString()), transform(NewObjectId.ToHexString()));
 }
 protected virtual string GetBuildFormat(TextElement text)
 {
     return text.BuildFormat;
 }
 protected override string GetFormat(TextElement text)
 {
     return text.RepositoryCreatedFormat;
 }
        public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
        {
            var lines = new List<string>();
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                ProjectName = transform(ProjectName),
                WiUrl,
                WiType = transform(WiType),
                WiId,
                WiTitle = transform(WiTitle),
                IsStateChanged,
                IsAssignmentChanged,
                AssignedTo = transform(AssignedTo),
                State = transform(State),
                UserName = transform(UserName),
                Action = FormatAction(text),
                AssignedToUserName = transform(AssignedToUserName),
                MappedAssignedToUser = bot.GetMappedUser(AssignedToUniqueName),
                MappedUser = bot.GetMappedUser(UniqueName)
            };
            lines.Add(text.WorkItemchangedFormat.FormatWith(formatter));

            var searchType = IsNew ? SearchFieldsType.Core : SearchFieldsType.Changed;
            var displayFieldsKey = IsNew ? "wiCreatedDisplayFields" : "wiChangedDisplayFields";
            var pattern = IsNew ? "{name}: {newValue}" : "{name}: " + text.WorkItemFieldTransitionFormat;

            foreach (var fieldId in bot.GetCsvSetting(displayFieldsKey, Defaults.WorkItemFields))
            {
                var field = GetUnifiedField(fieldId, searchType);
                if (field != null)
                    lines.Add(pattern.FormatWith(field));
                }

            return lines;
        }
Beispiel #28
0
 public override string ToString(BotElement bot, TextElement text, Func<string, string> transform)
 {
     return $"{Refs.ToString(text, transform)} {text.Deleted}";
 }
        public override IList<string> ToMessage(BotElement bot, TextElement text, Func<string, string> transform)
        {
            var formatter = new
            {
                TeamProjectCollection = transform(TeamProjectCollection),
                DisplayName = transform(DisplayName),
                ProjectName = transform(ProjectName),
                RepoUri,
                RepoName = transform(RepoName),
                CommitId = transform(CommitId.ToHexString(Settings.HashLength)),
                CommitUri,
                Comment = transform(Comment),
                UserName = transform(UserName),
                PusherUserName = transform(PusherUserName),
                MappedPusherUser = bot.GetMappedUser(PusherUniqueName),
                MappedUser = bot.GetMappedUser(UniqueName)
            };

            return new[] { text.CommitCommentFormat.FormatWith(formatter), Comment };
        }