Exemple #1
0
        private System.Drawing.Rectangle _headerResize; // Cache desired size for commit header

        private void ReloadCommitInfo()
        {
            _RevisionHeader.BackColor = ColorHelper.MakeColorDarker(BackColor);

            showContainedInBranchesToolStripMenuItem.Checked                = AppSettings.CommitInfoShowContainedInBranchesLocal;
            showContainedInBranchesRemoteToolStripMenuItem.Checked          = AppSettings.CommitInfoShowContainedInBranchesRemote;
            showContainedInBranchesRemoteIfNoLocalToolStripMenuItem.Checked = AppSettings.CommitInfoShowContainedInBranchesRemoteIfNoLocal;
            showContainedInTagsToolStripMenuItem.Checked         = AppSettings.CommitInfoShowContainedInTags;
            showMessagesOfAnnotatedTagsToolStripMenuItem.Checked = AppSettings.ShowAnnotatedTagsMessages;

            ResetTextAndImage();

            if (string.IsNullOrEmpty(_revision.Guid))
            {
                return; //is it regular case or should throw an exception
            }
            _RevisionHeader.Text = string.Empty;
            _RevisionHeader.Refresh();
            string     error = "";
            CommitData data  = _commitDataManager.CreateFromRevision(_revision);

            if (_revision.Body == null)
            {
                _commitDataManager.UpdateCommitMessage(data, _revision.Guid, ref error);
                _revision.Body = data.Body;
            }

            ThreadPool.QueueUserWorkItem(_ => loadLinksForRevision(_revision));

            if (_sortedRefs == null)
            {
                ThreadPool.QueueUserWorkItem(_ => loadSortedRefs());
            }

            data.ChildrenGuids = _children;
            var header = _commitDataHeaderRenderer.Render(data, CommandClick != null);
            var body   = _commitDataBodyRenderer.Render(data, CommandClick != null);

            _RevisionHeader.SetXHTMLText(header);
            _RevisionHeader.Height = GetRevisionHeaderHeight();
            _revisionInfo          = body;

            UpdateRevisionInfo();
            LoadAuthorImage(data.Author ?? data.Committer);

            if (AppSettings.CommitInfoShowContainedInBranches)
            {
                ThreadPool.QueueUserWorkItem(_ => loadBranchInfo(_revision.Guid));
            }

            if (AppSettings.ShowAnnotatedTagsMessages)
            {
                ThreadPool.QueueUserWorkItem(_ => loadAnnotatedTagInfo(_revision));
            }

            if (AppSettings.CommitInfoShowContainedInTags)
            {
                ThreadPool.QueueUserWorkItem(_ => loadTagInfo(_revision.Guid));
            }
        }
        /// <summary>
        /// Gets the commit info from CommitData.
        /// </summary>
        /// <returns></returns>
        public CommitInformation Get(CommitData data, bool showRevisionsAsLinks)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var header = _commitDataHeaderRenderer.Render(data, showRevisionsAsLinks);
            var body   = "\n" + WebUtility.HtmlEncode((data.Body ?? "").Trim());

            if (showRevisionsAsLinks)
            {
                body = GitRevision.Sha1HashShortRegex.Replace(body, match => ProcessHashCandidate(match.Value));
            }

            return(new CommitInformation(header, body));
        }
        public void GetCommitInfo_should_provide_information_without_revisions()
        {
            var header = @"Author:      <a href='mailto:[email protected]'>John Doe (Acme Inc) &lt;[email protected]&gt;</a>
Date:        6 days ago (10/12/2017 10:52:13 PM)
Committer:   <a href='mailto:[email protected]'>John Doe &lt;[email protected]&gt;</a>
Commit hash: c3c03473f3bc7fb3807b3132a20ac70743cdbda3
Parent(s):   a2b24c7f6e
";

            _commitInfoRenderer.Render(Arg.Any <CommitData>(), false).Returns(x => header);

            var result = _provider.Get(_data, false);

            result.Should().NotBeNull();
            result.Header.Should().Be(header);
            result.Body.Should().Be("\n" + _data.Body.Trim());
        }
        public void ShowCommitInfo(GitRevision revision, IReadOnlyList <ObjectId> children)
        {
            this.InvokeAsync(() =>
            {
                rtbRevisionHeader.Clear();

                var data   = _commitDataManager.CreateFromRevision(revision, children);
                var header = _commitDataHeaderRenderer.Render(data, showRevisionsAsLinks: CommandClicked != null);

                rtbRevisionHeader.SuspendLayout();
                rtbRevisionHeader.SetXHTMLText(header);
                rtbRevisionHeader.SelectionStart = 0; // scroll up
                rtbRevisionHeader.ScrollToCaret();    // scroll up
                rtbRevisionHeader.ResumeLayout(true);

                LoadAuthorImage(revision);
            }).FileAndForget();
        }
        public void Setup()
        {
            _data = new CommitData("c3c03473f3bc7fb3807b3132a20ac70743cdbda3", Guid.NewGuid().ToString(),
                                   new ReadOnlyCollection <string>(new List <string> {
                "a2b24c7f6ed5dacbac5470561914fcb27a992024"
            }),
                                   "John Doe (Acme Inc) <*****@*****.**>", DateTime.UtcNow,
                                   "John Doe <*****@*****.**>", DateTime.UtcNow,
                                   "\tI made a really neato change.\n\nNotes (p4notes):\n\tP4@547123");

            _linkFactory = Substitute.For <ILinkFactory>();

            _commitInfoRenderer = Substitute.For <ICommitDataHeaderRenderer>();
            _commitInfoRenderer.Render(Arg.Any <CommitData>(), true).Returns(x => null);

            _module    = Substitute.For <IGitModule>();
            _getModule = () => _module;

            _provider = new CommitInformationProvider(_getModule, _linkFactory, _commitInfoRenderer);
        }