Пример #1
0
        /// <summary>
        /// Generate header.
        /// </summary>
        /// <returns></returns>
        public string GetHeader(bool showRevisionsAsLinks)
        {
            StringBuilder header      = new StringBuilder();
            string        authorEmail = GetEmail(Author);

            header.AppendLine(FillToLength(WebUtility.HtmlEncode(Strings.GetAuthorText()) + ":", COMMITHEADER_STRING_LENGTH) +
                              "<a href='mailto:" + WebUtility.HtmlEncode(authorEmail) + "'>" + WebUtility.HtmlEncode(Author) + "</a>");
            header.AppendLine(FillToLength(WebUtility.HtmlEncode(Strings.GetAuthorDateText()) + ":", COMMITHEADER_STRING_LENGTH) +
                              WebUtility.HtmlEncode(GitCommandHelpers.GetRelativeDateString(DateTime.UtcNow, AuthorDate.UtcDateTime) + " (" + GitCommandHelpers.GetFullDateString(AuthorDate) + ")"));
            string committerEmail = GetEmail(Committer);

            header.AppendLine(FillToLength(WebUtility.HtmlEncode(Strings.GetCommitterText()) + ":", COMMITHEADER_STRING_LENGTH) +
                              "<a href='mailto:" + WebUtility.HtmlEncode(committerEmail) + "'>" + WebUtility.HtmlEncode(Committer) + "</a>");
            header.AppendLine(FillToLength(WebUtility.HtmlEncode(Strings.GetCommitDateText()) + ":", COMMITHEADER_STRING_LENGTH) +
                              WebUtility.HtmlEncode(GitCommandHelpers.GetRelativeDateString(DateTime.UtcNow, CommitDate.UtcDateTime) + " (" + GitCommandHelpers.GetFullDateString(CommitDate) + ")"));
            header.Append(FillToLength(WebUtility.HtmlEncode(Strings.GetCommitHashText()) + ":", COMMITHEADER_STRING_LENGTH) +
                          WebUtility.HtmlEncode(Guid));

            if (ChildrenGuids != null && ChildrenGuids.Count != 0)
            {
                header.AppendLine();
                string commitsString;
                if (showRevisionsAsLinks)
                {
                    commitsString = ChildrenGuids.Select(LinkFactory.CreateCommitLink).Join(" ");
                }
                else
                {
                    commitsString = ChildrenGuids.Select(guid => guid.Substring(0, 10)).Join(" ");
                }
                header.Append(FillToLength(WebUtility.HtmlEncode(Strings.GetChildrenText()) + ":",
                                           COMMITHEADER_STRING_LENGTH) + commitsString);
            }

            var parentGuids = ParentGuids.Where(s => !string.IsNullOrEmpty(s));

            if (parentGuids.Any())
            {
                header.AppendLine();
                string commitsString;
                if (showRevisionsAsLinks)
                {
                    commitsString = parentGuids.Select(LinkFactory.CreateCommitLink).Join(" ");
                }
                else
                {
                    commitsString = parentGuids.Select(guid => guid.Substring(0, 10)).Join(" ");
                }
                header.Append(FillToLength(WebUtility.HtmlEncode(Strings.GetParentsText()) + ":",
                                           COMMITHEADER_STRING_LENGTH) + commitsString);
            }

            return(RemoveRedundancies(header.ToString()));
        }
Пример #2
0
        /// <summary>
        /// Generate header.
        /// </summary>
        /// <returns></returns>
        public string GetHeaderPlain()
        {
            StringBuilder header = new StringBuilder();

            header.AppendLine(FillToLength(Strings.GetAuthorText() + ":", COMMITHEADER_STRING_LENGTH) + Author);
            header.AppendLine(FillToLength(Strings.GetAuthorDateText() + ":", COMMITHEADER_STRING_LENGTH) +
                              GitCommandHelpers.GetRelativeDateString(DateTime.UtcNow, AuthorDate.UtcDateTime) + " (" + GitCommandHelpers.GetFullDateString(AuthorDate) + ")");
            header.AppendLine(FillToLength(Strings.GetCommitterText() + ":", COMMITHEADER_STRING_LENGTH) +
                              Committer);
            header.AppendLine(FillToLength(Strings.GetCommitDateText() + ":", COMMITHEADER_STRING_LENGTH) +
                              GitCommandHelpers.GetRelativeDateString(DateTime.UtcNow, CommitDate.UtcDateTime) + " (" + GitCommandHelpers.GetFullDateString(CommitDate) + ")");
            header.Append(FillToLength(Strings.GetCommitHashText() + ":", COMMITHEADER_STRING_LENGTH) +
                          Guid);

            return(RemoveRedundancies(header.ToString()));
        }