public void TestToString() { DateTime committerTime = DateTime.Now; DateTime authorTime = DateTime.Now; StringBuilder expectedHeader = new StringBuilder(); expectedHeader.AppendLine("Author: Author"); expectedHeader.AppendLine("AuthorTime: " + authorTime.ToString()); expectedHeader.AppendLine("Committer: committer"); expectedHeader.AppendLine("CommitterTime: " + committerTime.ToString()); expectedHeader.AppendLine("Summary: test summary"); expectedHeader.AppendLine(); expectedHeader.Append("FileName: fileName.txt"); GitBlameHeader header = new GitBlameHeader { Author = "Author", AuthorMail = "*****@*****.**", AuthorTime = authorTime, Committer = "committer", CommitterTime = committerTime, Summary = "test summary", FileName = "fileName.txt" }; Assert.AreEqual(expectedHeader.ToString(), header.ToString()); }
void BlameCommitter_MouseMove(object sender, MouseEventArgs e) { if (!BlameFile.Focused) { BlameFile.Focus(); } if (_blame == null) { return; } int line = BlameCommitter.GetLineFromVisualPosY(e.Y); if (line >= _blame.Lines.Count) { return; } GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(_blame.Lines[line].CommitGuid); string tooltipText = blameHeader.ToString(); int newTooltipX = splitContainer2.SplitterDistance + 60; int newTooltipY = e.Y + splitContainer1.SplitterDistance + 20; if (lastTooltip != tooltipText || Math.Abs(lastTooltipX - newTooltipX) > 5 || Math.Abs(lastTooltipY - newTooltipY) > 5) { lastTooltip = tooltipText; lastTooltipX = newTooltipX; lastTooltipY = newTooltipY; blameTooltip.Show(tooltipText, this, newTooltipX, newTooltipY); } }
void BlameFile_MouseMove(object sender, MouseEventArgs e) { if (_blame == null) { return; } int line = BlameFile.GetLineFromVisualPosY(e.Y); if (line >= _blame.Lines.Count) { return; } GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(_blame.Lines[line].CommitGuid); if (blameHeader != lastBlameHeader) { BlameCommitter.ClearHighlighting(); BlameFile.ClearHighlighting(); for (int i = 0; i < _blame.Lines.Count; i++) { if (_blame.Lines[i].CommitGuid == blameHeader.CommitGuid) { BlameCommitter.HighlightLine(i, Color.FromArgb(225, 225, 225)); BlameFile.HighlightLine(i, Color.FromArgb(225, 225, 225)); } } BlameCommitter.Refresh(); BlameFile.Refresh(); lastBlameHeader = blameHeader; } }
public void LoadBlame(string guid, string fileName, RevisionGrid revGrid) { var scrollpos = BlameFile.ScrollPos; var blameCommitter = new StringBuilder(); var blameFile = new StringBuilder(); _revGrid = revGrid; _blame = GitCommandHelpers.Blame(fileName, guid); for (int i = 0; i < _blame.Lines.Count; i++) { GitBlameLine blameLine = _blame.Lines[i]; GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(blameLine.CommitGuid); if (i > 0 && _blame.Lines[i - 1].CommitGuid == blameLine.CommitGuid) { blameCommitter.AppendLine(new string(' ', 200)); } else { blameCommitter.AppendLine((blameHeader.Author + " - " + blameHeader.AuthorTime.ToString() + " - " + blameHeader.FileName + new string(' ', 100)).Trim(new char[] { '\r', '\n' })); } blameFile.AppendLine(blameLine.LineText.Trim(new char[] { '\r', '\n' })); } BlameCommitter.ViewText("committer.txt", blameCommitter.ToString()); BlameFile.ViewText(fileName, blameFile.ToString()); BlameFile.ScrollPos = scrollpos; BlameFile_SelectedLineChanged(null, 0); }
public void TestEqualsFails() { GitBlameHeader header1 = new GitBlameHeader { Author = "Author" }; GitBlameHeader header2 = new GitBlameHeader(); Assert.IsFalse(header1.Equals(header2)); }
public void TestGetColor() { string randomGuid = "b35a3233-8345-43aa-a618-2ca0de12000c"; GitBlameHeader header = new GitBlameHeader { CommitGuid = randomGuid }; Color expectedColor = Color.FromArgb(255, 246, 226, 238); Assert.AreEqual(expectedColor, header.GetColor()); }
private void copyLogMessageToolStripMenuItem_Click(object sender, EventArgs e) { string commit = GetBlameCommit(); if (commit == null) { return; } GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(commit); Clipboard.SetText(blameHeader.Summary); }
public void TestFindHeaderForCommitGuid() { GitBlame blame = new GitBlame(); string expectedCommitGuid = Guid.NewGuid().ToString(); GitBlameHeader expectedHeader = new GitBlameHeader { CommitGuid = expectedCommitGuid }; blame.Headers.Add(expectedHeader); Assert.IsTrue(blame.FindHeaderForCommitGuid(expectedCommitGuid).Equals(expectedHeader)); }
private void BlameFile_MouseMove(object sender, MouseEventArgs e) { if (_blame == null) { return; } int line = BlameFile.GetLineFromVisualPosY(e.Y); if (line >= _blame.Lines.Count) { return; } GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(_blame.Lines[line].CommitGuid); if (blameHeader != _lastBlameHeader) { BlameCommitter.ClearHighlighting(); BlameFile.ClearHighlighting(); int startLine = -1; int prevLine = -1; for (int i = 0; i < _blame.Lines.Count; i++) { if (_blame.Lines[i].CommitGuid == blameHeader.CommitGuid) { if (prevLine != i - 1 && startLine != -1) { BlameCommitter.HighlightLines(startLine, prevLine, Color.FromArgb(225, 225, 225)); BlameFile.HighlightLines(startLine, prevLine, Color.FromArgb(225, 225, 225)); startLine = -1; } prevLine = i; if (startLine == -1) { startLine = i; } } } if (startLine != -1) { BlameCommitter.HighlightLines(startLine, prevLine, Color.FromArgb(225, 225, 225)); BlameFile.HighlightLines(startLine, prevLine, Color.FromArgb(225, 225, 225)); } BlameCommitter.Refresh(); BlameFile.Refresh(); _lastBlameHeader = blameHeader; } }
private void ProcessBlame(GitRevision revision, List <string> children, Control controlToMask, int line, int scrollpos) { var blameCommitter = new StringBuilder(); var blameFile = new StringBuilder(); for (int i = 0; i < _blame.Lines.Count; i++) { GitBlameLine blameLine = _blame.Lines[i]; GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(blameLine.CommitGuid); if (i > 0 && _blame.Lines[i - 1].CommitGuid == blameLine.CommitGuid) { blameCommitter.AppendLine(new string(' ', 200)); } else { blameCommitter.AppendLine( (blameHeader.Author + " - " + blameHeader.AuthorTime + " - " + blameHeader.FileName + new string(' ', 100)).Trim(new[] { '\r', '\n' })); } if (blameLine.LineText == null) { blameFile.AppendLine(""); } else { blameFile.AppendLine(blameLine.LineText.Trim(new[] { '\r', '\n' })); } } BlameCommitter.ViewText("committer.txt", blameCommitter.ToString()); BlameFile.ViewText(_fileName, blameFile.ToString()); if (line > 0) { BlameFile.GoToLine(line - 1); } else { BlameFile.ScrollPos = scrollpos; } _clickedBlameLine = new GitBlameLine(); _blameHash = revision.Guid; CommitInfo.SetRevisionWithChildren(revision, children); if (controlToMask != null) { controlToMask.UnMask(); } }
void BlameFile_MouseMove(object sender, MouseEventArgs e) { if (_blame == null) { return; } int line = BlameFile.GetLineFromVisualPosY(e.Y); if (line >= _blame.Lines.Count) { return; } GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(_blame.Lines[line].CommitGuid); string tooltipText = blameHeader.ToString(); if (lastTooltip != tooltipText) { BlameCommitter.ClearHighlighting(); BlameFile.ClearHighlighting(); for (int i = 0; i < _blame.Lines.Count; i++) { if (_blame.Lines[i].CommitGuid == blameHeader.CommitGuid) { BlameCommitter.HighlightLine(i, Color.FromArgb(225, 225, 225)); BlameFile.HighlightLine(i, Color.FromArgb(225, 225, 225)); } } BlameCommitter.Refresh(); BlameFile.Refresh(); } int newTooltipX = e.X + splitContainer2.SplitterDistance + 20; int newTooltipY = e.Y + splitContainer1.SplitterDistance + 20; if (lastTooltip != tooltipText || Math.Abs(lastTooltipX - newTooltipX) > 5 || Math.Abs(lastTooltipY - newTooltipY) > 5) { lastTooltip = tooltipText; lastTooltipX = newTooltipX; lastTooltipY = newTooltipY; //blameTooltip.Show(tooltipText, this, newTooltipX, newTooltipY); } }
public void LoadBlame(string guid, string fileName, RevisionGrid revGrid) { var scrollpos = BlameFile.ScrollPos; var blameCommitter = new StringBuilder(); var blameFile = new StringBuilder(); _revGrid = revGrid; _blame = Settings.Module.Blame(fileName, guid); for (int i = 0; i < _blame.Lines.Count; i++) { GitBlameLine blameLine = _blame.Lines[i]; GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(blameLine.CommitGuid); if (i > 0 && _blame.Lines[i - 1].CommitGuid == blameLine.CommitGuid) { blameCommitter.AppendLine(new string(' ', 200)); } else { blameCommitter.AppendLine((blameHeader.Author + " - " + blameHeader.AuthorTime + " - " + blameHeader.FileName + new string(' ', 100)).Trim(new[] { '\r', '\n' })); } if (blameLine.LineText == null) { blameFile.AppendLine(""); } else { blameFile.AppendLine(blameLine.LineText.Trim(new char[] { '\r', '\n' })); } } BlameCommitter.ViewText("committer.txt", blameCommitter.ToString()); BlameFile.ViewText(fileName, blameFile.ToString()); BlameFile.ScrollPos = scrollpos; commitInfo.SetRevision(guid); }
public void TestConstructor() { GitBlameHeader header = new GitBlameHeader(); Assert.IsNotNull(header); }
public void LoadBlame(GitRevision revision, List <string> children, string fileName, RevisionGrid revGrid, Control controlToMask, Encoding encoding) { string guid = revision.Guid; //refresh only when something changed if (guid.Equals(CommitInfo.Revision) && fileName.Equals(fileName) && revGrid == _revGrid && encoding == _encoding) { return; } if (controlToMask != null) { controlToMask.Mask(); } var scrollpos = BlameFile.ScrollPos; var blameCommitter = new StringBuilder(); var blameFile = new StringBuilder(); _revGrid = revGrid; _fileName = fileName; _encoding = encoding; blameLoader.Load(() => { _blame = Module.Blame(fileName, guid, encoding); }, () => { for (int i = 0; i < _blame.Lines.Count; i++) { GitBlameLine blameLine = _blame.Lines[i]; GitBlameHeader blameHeader = _blame.FindHeaderForCommitGuid(blameLine.CommitGuid); if (i > 0 && _blame.Lines[i - 1].CommitGuid == blameLine.CommitGuid) { blameCommitter.AppendLine(new string(' ', 200)); } else { blameCommitter.AppendLine((blameHeader.Author + " - " + blameHeader.AuthorTime + " - " + blameHeader.FileName + new string(' ', 100)).Trim(new[] { '\r', '\n' })); } if (blameLine.LineText == null) { blameFile.AppendLine(""); } else { blameFile.AppendLine(blameLine.LineText.Trim(new char[] { '\r', '\n' })); } } BlameCommitter.ViewText("committer.txt", blameCommitter.ToString()); BlameFile.ViewText(fileName, blameFile.ToString()); BlameFile.ScrollPos = scrollpos; CommitInfo.SetRevisionWithChildren(revision, children); if (controlToMask != null) { controlToMask.UnMask(); } }); }