Skip to content

Commit 59d6604

Browse files
committed
feat: use dirty mark instead of local changes count in Welcome page (#2891)
1 parent 9bdbc66 commit 59d6604

3 files changed

Lines changed: 10 additions & 17 deletions

File tree

‎src/Commands/QueryRepositoryStatus.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public QueryRepositoryStatus(string repo)
1717

1818
public async Task<Models.RepositoryStatus> GetResultAsync()
1919
{
20-
Args = "status --porcelain=v2 -b -uall --ignore-submodules=dirty";
20+
Args = "status --porcelain=v2 -b -unormal --ignore-submodules=dirty";
2121
var rs = await ReadToEndAsync().ConfigureAwait(false);
2222
if (!rs.IsSuccess)
2323
return null;
@@ -36,7 +36,7 @@ public QueryRepositoryStatus(string repo)
3636
else
3737
status.CurrentBranch = head;
3838

39-
var localChanges = 0;
39+
var hasLocalChanges = false;
4040
for (var i = 2; i < count; i++)
4141
{
4242
var line = lines[i];
@@ -47,11 +47,11 @@ public QueryRepositoryStatus(string repo)
4747
}
4848
else
4949
{
50-
localChanges++;
50+
hasLocalChanges = true;
5151
}
5252
}
5353

54-
status.LocalChanges = localChanges;
54+
status.HasLocalChanges = hasLocalChanges;
5555
return status;
5656
}
5757

‎src/Models/RepositoryStatus.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class RepositoryStatus
55
public string CurrentBranch { get; set; } = string.Empty;
66
public int Ahead { get; set; } = 0;
77
public int Behind { get; set; } = 0;
8-
public int LocalChanges { get; set; } = 0;
8+
public bool HasLocalChanges { get; set; } = false;
99

1010
public bool IsTrackingStatusVisible
1111
{

‎src/Views/Welcome.axaml‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,11 @@
171171
<ContentControl.DataTemplates>
172172
<DataTemplate DataType="m:RepositoryStatus">
173173
<StackPanel Orientation="Horizontal">
174-
<Border Margin="3,0"
175-
Height="18"
176-
CornerRadius="9"
177-
Padding="6,0"
178-
Background="{DynamicResource Brush.FG1}"
179-
VerticalAlignment="Center"
180-
IsVisible="{Binding LocalChanges, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
181-
<TextBlock Text="{Binding LocalChanges}"
182-
FontFamily="{DynamicResource Fonts.Monospace}"
183-
FontSize="11"
184-
Foreground="{DynamicResource Brush.Window}"/>
185-
</Border>
174+
<Ellipse Margin="3,0"
175+
Width="8" Height="8"
176+
Fill="Gray"
177+
VerticalAlignment="Center"
178+
IsVisible="{Binding HasLocalChanges}"/>
186179

187180
<TextBlock Margin="3,0"
188181
Text="{Binding TrackingDescription}"

0 commit comments

Comments
 (0)