From ac57c930cb5d28956726cdfb229b1027fb89e0aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernat=20Borr=C3=A0s=20Civil?=
<70479573+BernatBC@users.noreply.github.com>
Date: Sun, 19 Jan 2025 17:13:15 +0100
Subject: [PATCH] Display lines changed
---
src/Commands/QueryCommitChangedLines.cs | 6 ++--
src/Models/Commit.cs | 3 ++
src/ViewModels/CommitDetail.cs | 8 +++--
src/Views/CommitBaseInfo.axaml | 21 ++++++++++++-
src/Views/LinesChanged.axaml | 26 ----------------
src/Views/LinesChanged.axaml.cs | 41 -------------------------
6 files changed, 32 insertions(+), 73 deletions(-)
delete mode 100644 src/Views/LinesChanged.axaml
delete mode 100644 src/Views/LinesChanged.axaml.cs
diff --git a/src/Commands/QueryCommitChangedLines.cs b/src/Commands/QueryCommitChangedLines.cs
index d5605104..018072cc 100644
--- a/src/Commands/QueryCommitChangedLines.cs
+++ b/src/Commands/QueryCommitChangedLines.cs
@@ -31,8 +31,10 @@ namespace SourceGit.Commands
if (parts.Length >= 2)
{
- _addedLines += int.Parse(parts[0]);
- _removedLines += int.Parse(parts[1]);
+ bool canParseAdded = int.TryParse(parts[0], out int addedLines);
+ bool canParseRemoved = int.TryParse(parts[1], out int removedLines);
+ if (canParseAdded) _addedLines += addedLines;
+ if (canParseRemoved) _removedLines += removedLines;
}
}
diff --git a/src/Models/Commit.cs b/src/Models/Commit.cs
index 9bc7f0c3..3840f62e 100644
--- a/src/Models/Commit.cs
+++ b/src/Models/Commit.cs
@@ -45,6 +45,9 @@ namespace SourceGit.Models
public Thickness Margin { get; set; } = new Thickness(0);
public IBrush Brush => CommitGraph.Pens[Color].Brush;
+ public int AddedLines { get; set; } = 0;
+ public int RemovedLines { get; set; } = 0;
+
public void ParseDecorators(string data)
{
if (data.Length < 3)
diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs
index 455c530d..d2cc0b06 100644
--- a/src/ViewModels/CommitDetail.cs
+++ b/src/ViewModels/CommitDetail.cs
@@ -637,9 +637,11 @@ namespace SourceGit.ViewModels
Task.Run(() =>
{
- var lines = new Commands.QueryCommitChangedLines(_repo.FullPath, _commit.SHA).Result();
- Console.WriteLine(lines);
- //Dispatcher.UIThread.Invoke(() => FullMessage = fullMessage);
+ (var addedLines, var removedLines) = new Commands.QueryCommitChangedLines(_repo.FullPath, _commit.SHA).Result();
+ Dispatcher.UIThread.Invoke(() => {
+ _commit.AddedLines = addedLines;
+ _commit.RemovedLines = removedLines;
+ });
});
Task.Run(() =>
diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml
index 55342d18..b62ecc92 100644
--- a/src/Views/CommitBaseInfo.axaml
+++ b/src/Views/CommitBaseInfo.axaml
@@ -184,7 +184,26 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Views/LinesChanged.axaml b/src/Views/LinesChanged.axaml
deleted file mode 100644
index b8a32d00..00000000
--- a/src/Views/LinesChanged.axaml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Views/LinesChanged.axaml.cs b/src/Views/LinesChanged.axaml.cs
deleted file mode 100644
index aa2c8a60..00000000
--- a/src/Views/LinesChanged.axaml.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-
-namespace SourceGit.Views
-{
- public partial class LinesChanged : UserControl
- {
- public static readonly DirectProperty AddedLinesProperty =
- AvaloniaProperty.RegisterDirect(nameof(AddedLines), o => o.AddedLines);
-
- public static readonly DirectProperty RemovedLinesProperty =
- AvaloniaProperty.RegisterDirect(nameof(RemovedLines), o => o.RemovedLines);
-
- private int _addedLines;
- private int _removedLines;
-
- public int AddedLines
- {
- get => _addedLines;
- set => SetAndRaise(AddedLinesProperty, ref _addedLines, value);
- }
-
- public int RemovedLines
- {
- get => _removedLines;
- set => SetAndRaise(RemovedLinesProperty, ref _removedLines, value);
- }
-
- public LinesChanged()
- {
- InitializeComponent();
- this.DataContext = this;
- }
-
- private void InitializeComponent()
- {
- AvaloniaXamlLoader.Load(this);
- }
- }
-}