コード例 #1
0
ファイル: CommitDataExt.cs プロジェクト: zlolik/gitextensions
        /// <summary>
        /// Generate header.
        /// </summary>
        /// <param name="commitData"></param>
        /// <returns></returns>
        public static string GetHeaderPlain(this CommitData commitData)
        {
            StringBuilder header           = new StringBuilder();
            bool          authorIsCommiter = String.Equals(commitData.Author, commitData.Committer, StringComparison.CurrentCulture);
            bool          datesEqual       = commitData.AuthorDate.EqualsExact(commitData.CommitDate);

            header.AppendLine((Strings.GetAuthorText() + ":").PadRight(GetHeaderPadding()) +
                              commitData.Author);

            header.AppendLine((datesEqual ? Strings.GetDateText() : Strings.GetAuthorDateText() + ":").PadRight(GetHeaderPadding()) +
                              LocalizationHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.AuthorDate.UtcDateTime) +
                              " (" + LocalizationHelpers.GetFullDateString(commitData.AuthorDate) + ")");
            if (!authorIsCommiter)
            {
                header.AppendLine((Strings.GetCommitterText() + ":").PadRight(GetHeaderPadding()) +
                                  commitData.Committer);
            }
            if (!datesEqual)
            {
                header.AppendLine((Strings.GetCommitDateText() + ":").PadRight(GetHeaderPadding()) +
                                  LocalizationHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.CommitDate.UtcDateTime) +
                                  " (" + LocalizationHelpers.GetFullDateString(commitData.CommitDate) + ")");

                header.Append((Strings.GetCommitHashText() + ":").PadRight(GetHeaderPadding()) +
                              commitData.Guid);
            }

            return(header.ToString());
        }
コード例 #2
0
        /// <summary>
        /// Generate header.
        /// </summary>
        /// <param name="commitData"></param>
        /// <returns></returns>
        public static string GetHeaderPlain(this CommitData commitData)
        {
            StringBuilder header = new StringBuilder();

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

            return(RemoveRedundancies(header.ToString()));
        }
コード例 #3
0
        /// <inheritdoc />
        /// <summary>
        /// Generate header.
        /// </summary>
        /// <param name="commitData"></param>
        /// <returns></returns>
        public string RenderPlain(CommitData commitData)
        {
            if (commitData == null)
            {
                throw new ArgumentNullException(nameof(commitData));
            }

            StringBuilder header           = new StringBuilder();
            bool          authorIsCommiter = string.Equals(commitData.Author, commitData.Committer, StringComparison.CurrentCulture);
            bool          datesEqual       = commitData.AuthorDate.EqualsExact(commitData.CommitDate);

            header.AppendLine((Strings.GetAuthorText() + ":").PadRight(GetHeaderPadding()) +
                              commitData.Author);

            header.AppendLine((datesEqual ? Strings.GetDateText() : Strings.GetAuthorDateText() + ":").PadRight(GetHeaderPadding()) +
                              LocalizationHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.AuthorDate.UtcDateTime) +
                              " (" + LocalizationHelpers.GetFullDateString(commitData.AuthorDate) + ")");
            if (!authorIsCommiter)
            {
                header.AppendLine((Strings.GetCommitterText() + ":").PadRight(GetHeaderPadding()) +
                                  commitData.Committer);
            }
            if (!datesEqual)
            {
                header.AppendLine((Strings.GetCommitDateText() + ":").PadRight(GetHeaderPadding()) +
                                  LocalizationHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.CommitDate.UtcDateTime) +
                                  " (" + LocalizationHelpers.GetFullDateString(commitData.CommitDate) + ")");

                header.Append((Strings.GetCommitHashText() + ":").PadRight(GetHeaderPadding()) +
                              commitData.Guid);
            }

            header.Append(
                (WebUtility.HtmlEncode(Strings.GetCommitHashText()) + ":").PadRight(GetHeaderPadding()) +
                WebUtility.HtmlEncode(commitData.Guid));

            return(header.ToString());
        }
コード例 #4
0
        /// <summary>
        /// Generate header.
        /// </summary>
        /// <returns></returns>
        public static string GetHeader(this CommitData commitData, bool showRevisionsAsLinks)
        {
            StringBuilder header      = new StringBuilder();
            string        authorEmail = GetEmail(commitData.Author);

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

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

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

            var parentGuids = commitData.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()));
        }
コード例 #5
0
ファイル: CommitDataExt.cs プロジェクト: zlolik/gitextensions
        /// <summary>
        /// Generate header.
        /// </summary>
        /// <returns></returns>
        public static string GetHeader(this CommitData commitData, LinkFactory linkFactory, bool showRevisionsAsLinks)
        {
            StringBuilder header           = new StringBuilder();
            bool          authorIsCommiter = String.Equals(commitData.Author, commitData.Committer, StringComparison.CurrentCulture);
            bool          datesEqual       = commitData.AuthorDate.EqualsExact(commitData.CommitDate);

            string authorEmail = GetEmail(commitData.Author);

            header.AppendLine(
                (WebUtility.HtmlEncode(Strings.GetAuthorText()) + ":").PadRight(GetHeaderPadding()) +
                linkFactory.CreateLink(commitData.Author, "mailto:" + authorEmail));
            header.AppendLine(
                (WebUtility.HtmlEncode(datesEqual ? Strings.GetDateText() :
                                       Strings.GetAuthorDateText()) + ":").PadRight(GetHeaderPadding()) +
                WebUtility.HtmlEncode(
                    LocalizationHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.AuthorDate.UtcDateTime) + " (" +
                    LocalizationHelpers.GetFullDateString(commitData.AuthorDate) + ")"));

            if (!authorIsCommiter)
            {
                string committerEmail = GetEmail(commitData.Committer);
                header.AppendLine(
                    (WebUtility.HtmlEncode(Strings.GetCommitterText()) + ":").PadRight(GetHeaderPadding()) +
                    "<a href='mailto:" + WebUtility.HtmlEncode(committerEmail) + "'>" +
                    WebUtility.HtmlEncode(commitData.Committer) + "</a>");
            }

            if (!datesEqual)
            {
                header.AppendLine(
                    (WebUtility.HtmlEncode(Strings.GetCommitDateText()) + ":").PadRight(GetHeaderPadding()) +
                    WebUtility.HtmlEncode(
                        LocalizationHelpers.GetRelativeDateString(DateTime.UtcNow, commitData.CommitDate.UtcDateTime) + " (" +
                        LocalizationHelpers.GetFullDateString(commitData.CommitDate) + ")"));
            }

            header.Append(
                (WebUtility.HtmlEncode(Strings.GetCommitHashText()) + ":").PadRight(GetHeaderPadding()) +
                WebUtility.HtmlEncode(commitData.Guid));

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

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

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

            return(header.ToString());
        }