private System.Drawing.Rectangle _headerResize; // Cache desired size for commit header private void ReloadCommitInfo() { _RevisionHeader.BackColor = ColorHelper.MakeColorDarker(this.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.SelectionTabs = GetRevisionHeaderTabStops(); _RevisionHeader.Text = string.Empty; _RevisionHeader.Refresh(); string error = ""; CommitData data = CommitData.CreateFromRevision(_revision); if (_revision.Body == null) { CommitData.UpdateCommitMessage(data, Module, _revision.Guid, ref error); _revision.Body = data.Body; } ThreadPool.QueueUserWorkItem(_ => loadLinksForRevision(_revision)); if (_sortedRefs == null) { ThreadPool.QueueUserWorkItem(_ => loadSortedRefs()); } data.ChildrenGuids = _children; CommitInformation commitInformation = CommitInformation.GetCommitInfo(data, _linkFactory, CommandClick != null, Module); _RevisionHeader.SetXHTMLText(commitInformation.Header); _RevisionHeader.Height = GetRevisionHeaderHeight(); _revisionInfo = commitInformation.Body; updateText(); 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)); } }
private void ReloadCommitInfo() { showContainedInBranchesToolStripMenuItem.Checked = Settings.CommitInfoShowContainedInBranchesLocal; showContainedInBranchesRemoteToolStripMenuItem.Checked = Settings.CommitInfoShowContainedInBranchesRemote; showContainedInBranchesRemoteIfNoLocalToolStripMenuItem.Checked = Settings.CommitInfoShowContainedInBranchesRemoteIfNoLocal; showContainedInTagsToolStripMenuItem.Checked = Settings.CommitInfoShowContainedInTags; ResetTextAndImage(); if (string.IsNullOrEmpty(_revision)) { return; } _RevisionHeader.Text = string.Empty; _RevisionHeader.Refresh(); CommitInformation commitInformation = CommitInformation.GetCommitInfo(_revision); _RevisionHeader.SetXHTMLText(commitInformation.Header); splitContainer1.SplitterDistance = _RevisionHeader.GetPreferredSize(new System.Drawing.Size(0, 0)).Height; _revisionInfo = commitInformation.Body; updateText(); LoadAuthorImage(); if (Settings.CommitInfoShowContainedInBranches) { ThreadPool.QueueUserWorkItem(_ => loadBranchInfo(_revision)); } if (Settings.CommitInfoShowContainedInTags) { ThreadPool.QueueUserWorkItem(_ => loadTagInfo(_revision)); } }
public void CanCreateCommitInformationFromFormatedData() { var commitGuid = Guid.NewGuid(); var treeGuid = Guid.NewGuid(); var parentGuid1 = Guid.NewGuid().ToString(); var parentGuid2 = Guid.NewGuid().ToString(); var authorTime = DateTime.UtcNow.AddDays(-3); var commitTime = DateTime.UtcNow.AddDays(-2); var authorUnixTime = (int)(authorTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var commitUnixTime = (int)(commitTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var revisionProvider = Substitute.For <IGitRevisionProvider>(); var parent1Rev = new GitRevision(aModule: null, guid: parentGuid1) { Subject = "Parent1" }; var parent2Rev = new GitRevision(aModule: null, guid: parentGuid2) { Subject = "Parent2" }; revisionProvider.GetRevision(parentGuid1, shortFormat: true).Returns(parent1Rev); revisionProvider.GetRevision(parentGuid2, shortFormat: true).Returns(parent2Rev); var rawData = commitGuid + "\n" + treeGuid + "\n" + parentGuid1 + " " + parentGuid2 + "\n" + "John Doe (Acme Inc) <*****@*****.**>\n" + authorUnixTime + "\n" + "Jane Doe (Acme Inc) <*****@*****.**>\n" + commitUnixTime + "\n" + "\n" + "\tI made a really neato change.\n\n" + "Notes (p4notes):\n" + "\tP4@547123"; var expectedHeader = "Author:\t\t<a href='mailto:[email protected]'>John Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Author date:\t3 days ago (" + LocalizationHelpers.GetFullDateString(authorTime) + ")" + Environment.NewLine + "Committer:\t<a href='mailto:[email protected]'>Jane Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Commit date:\t2 days ago (" + LocalizationHelpers.GetFullDateString(commitTime) + ")" + Environment.NewLine + "Commit hash:\t" + commitGuid + Environment.NewLine + "Parent(s):\t<a href='gitext://gotocommit/" + parentGuid1 + "'>" + parentGuid1.Substring(0, 10) + "</a> " + parent1Rev.Subject + Environment.NewLine + " \t\t<a href='gitext://gotocommit/" + parentGuid2 + "'>" + parentGuid2.Substring(0, 10) + "</a> " + parent2Rev.Subject; var expectedBody = "\nI made a really neato change." + Environment.NewLine + Environment.NewLine + "Notes (p4notes):" + Environment.NewLine + "\tP4@547123"; var commitData = CommitData.CreateFromFormatedData(rawData, new GitModule("")); var commitInformation = CommitInformation.GetCommitInfo(revisionProvider, commitData, true); Assert.AreEqual(expectedHeader, commitInformation.Header); Assert.AreEqual(expectedBody, commitInformation.Body); }
private void ReloadCommitInfo() { showContainedInBranchesToolStripMenuItem.Checked = Settings.CommitInfoShowContainedInBranchesLocal; showContainedInBranchesRemoteToolStripMenuItem.Checked = Settings.CommitInfoShowContainedInBranchesRemote; showContainedInBranchesRemoteIfNoLocalToolStripMenuItem.Checked = Settings.CommitInfoShowContainedInBranchesRemoteIfNoLocal; showContainedInTagsToolStripMenuItem.Checked = Settings.CommitInfoShowContainedInTags; ResetTextAndImage(); if (string.IsNullOrEmpty(_revisionGuid)) { return; //is it regular case or should throw an exception } _RevisionHeader.SelectionTabs = GetRevisionHeaderTabStops(); _RevisionHeader.Text = string.Empty; _RevisionHeader.Refresh(); string error = ""; CommitData data = null; if (_revision != null) { data = CommitData.CreateFromRevision(_revision); CommitData.UpdateCommitMessage(data, Module, _revisionGuid, ref error); } else { data = CommitData.GetCommitData(Module, _revisionGuid, ref error); } data.ChildrenGuids = _children; CommitInformation commitInformation = CommitInformation.GetCommitInfo(data); _RevisionHeader.SetXHTMLText(commitInformation.Header); _RevisionHeader.Height = _RevisionHeader.GetPreferredSize(new System.Drawing.Size(0, 0)).Height; _revisionInfo = commitInformation.Body; updateText(); LoadAuthorImage(data.Author ?? data.Committer); if (Settings.CommitInfoShowContainedInBranches) { ThreadPool.QueueUserWorkItem(_ => loadBranchInfo(_revisionGuid)); } if (Settings.CommitInfoShowContainedInTags) { ThreadPool.QueueUserWorkItem(_ => loadTagInfo(_revisionGuid)); } }
public void CanCreateCommitInformationFromFormatedData() { LinkFactory linkFactory = new LinkFactory(); var commitGuid = Guid.NewGuid(); var treeGuid = Guid.NewGuid(); var parentGuid1 = Guid.NewGuid().ToString(); var parentGuid2 = Guid.NewGuid().ToString(); var authorTime = DateTime.UtcNow.AddDays(-3); var commitTime = DateTime.UtcNow.AddDays(-2); var authorUnixTime = (int)(authorTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var commitUnixTime = (int)(commitTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var rawData = commitGuid + "\n" + treeGuid + "\n" + parentGuid1 + " " + parentGuid2 + "\n" + "John Doe (Acme Inc) <*****@*****.**>\n" + authorUnixTime + "\n" + "Jane Doe (Acme Inc) <*****@*****.**>\n" + commitUnixTime + "\n" + "\n" + "\tI made a really neato change.\n\n" + "Notes (p4notes):\n" + "\tP4@547123"; var expectedHeader = "Author: <a href='mailto:[email protected]'>John Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Author date: 3 days ago (" + LocalizationHelpers.GetFullDateString(authorTime) + ")" + Environment.NewLine + "Committer: <a href='mailto:[email protected]'>Jane Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Commit date: 2 days ago (" + LocalizationHelpers.GetFullDateString(commitTime) + ")" + Environment.NewLine + "Commit hash: " + commitGuid + Environment.NewLine + "Parent(s): <a href='gitext://gotocommit/" + parentGuid1 + "'>" + parentGuid1.Substring(0, 10) + "</a> <a href='gitext://gotocommit/" + parentGuid2 + "'>" + parentGuid2.Substring(0, 10) + "</a>"; var expectedBody = "\nI made a really neato change." + Environment.NewLine + Environment.NewLine + "Notes (p4notes):" + Environment.NewLine + "\tP4@547123"; // TEMP, will be refactored in the follow up refactor var commitData = new CommitDataManager(() => new GitModule("")).CreateFromFormatedData(rawData); var commitInformation = CommitInformation.GetCommitInfo(commitData, linkFactory, true); Assert.AreEqual(expectedHeader, commitInformation.Header); Assert.AreEqual(expectedBody, commitInformation.Body); }
public void CanCreateCommitInformationFromFormatedData() { var commitGuid = Guid.NewGuid(); var treeGuid = Guid.NewGuid(); var parentGuid1 = Guid.NewGuid().ToString(); var parentGuid2 = Guid.NewGuid().ToString(); var authorTime = DateTime.UtcNow.AddDays(-3); var commitTime = DateTime.UtcNow.AddDays(-2); var authorUnixTime = (int)(authorTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var commitUnixTime = (int)(commitTime - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds; var rawData = commitGuid + "\n" + treeGuid + "\n" + parentGuid1 + " " + parentGuid2 + "\n" + "John Doe (Acme Inc) <*****@*****.**>\n" + authorUnixTime + "\n" + "Jane Doe (Acme Inc) <*****@*****.**>\n" + commitUnixTime + "\n" + "\n" + "\tI made a really neato change.\n\n" + "Notes (p4notes):\n" + "\tP4@547123"; var expectedHeader = "Author:\t\t<a href='mailto:[email protected]'>John Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Author date:\t3 days ago (" + authorTime.ToLocalTime().ToString("ddd MMM dd HH':'mm':'ss yyyy") + ")" + Environment.NewLine + "Committer:\t<a href='mailto:[email protected]'>Jane Doe (Acme Inc) <[email protected]></a>" + Environment.NewLine + "Commit date:\t2 days ago (" + commitTime.ToLocalTime().ToString("ddd MMM dd HH':'mm':'ss yyyy") + ")" + Environment.NewLine + "Commit hash:\t" + commitGuid + Environment.NewLine + "Parent(s):\t<a href='gitex://gotocommit/" + parentGuid1 + "'>" + parentGuid1.Substring(0, 10) + "</a> <a href='gitex://gotocommit/" + parentGuid2 + "'>" + parentGuid2.Substring(0, 10) + "</a>"; var expectedBody = "\n\nI made a really neato change." + Environment.NewLine + Environment.NewLine + "Notes (p4notes):" + Environment.NewLine + "\tP4@547123\n\n"; var commitData = CommitData.CreateFromFormatedData(rawData, new GitModule("")); var commitInformation = CommitInformation.GetCommitInfo(commitData); Assert.AreEqual(expectedHeader, commitInformation.Header); Assert.AreEqual(expectedBody, commitInformation.Body); }
public void GetCommitInfoTestWhenDataIsNull() { var actualResult = CommitInformation.GetCommitInfo(new GitModule(""), "fakesha1"); Assert.AreEqual("Cannot find commit fakesha1", actualResult.Header); }
public void CanCreateCommitInformationFromFormatedDataThrowsException() { CommitInformation.GetCommitInfo(data: null); }
public void CanCreateCommitInformationFromFormatedDataThrowsException() { CommitInformation.GetCommitInfo(new GitModule(""), null, true); }
public void CanCreateCommitInformationFromFormatedDataThrowsException() { Assert.Throws <ArgumentNullException>(() => CommitInformation.GetCommitInfo(null, new LinkFactory(), true)); }
public void CanCreateCommitInformationFromFormatedDataThrowsException() { CommitInformation.GetCommitInfo(null, new LinkFactory(), true); }