fix: wrong graph when there's only one commit

This commit is contained in:
leo 2024-08-26 17:26:02 +08:00
parent ead2af7d65
commit 1dd782bc42
No known key found for this signature in database

View file

@ -191,6 +191,7 @@ namespace SourceGit.Models
}
isMerged = isMerged || l.IsMerged;
major.IsMerged = isMerged;
}
else
{
@ -202,12 +203,17 @@ namespace SourceGit.Models
}
// Create new curve for branch head
if (major == null && commit.Parents.Count > 0)
if (major == null)
{
offsetX += UNIT_WIDTH;
if (commit.Parents.Count > 0)
{
major = new PathHelper(commit.Parents[0], isMerged, colorIdx, new Point(offsetX, offsetY));
unsolved.Add(major);
temp.Paths.Add(major.Path);
}
colorIdx = (colorIdx + 1) % _penCount;
}
@ -216,11 +222,9 @@ namespace SourceGit.Models
int dotColor = 0;
if (major != null)
{
major.IsMerged = isMerged;
position = new Point(major.LastX, offsetY);
dotColor = major.Path.Color;
}
Dot anchor = new Dot() { Center = position, Color = dotColor };
if (commit.IsCurrentHead)
anchor.Type = DotType.Head;