Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Commands/Discard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ public static class Discard
/// </summary>
/// <param name="repo"></param>
/// <param name="includeIgnored"></param>
/// <param name="includeUntracked"></param>
/// <param name="log"></param>
public static async Task AllAsync(string repo, bool includeIgnored, Models.ICommandLog log)
public static async Task AllAsync(string repo, bool includeIgnored, bool includeUntracked, Models.ICommandLog log)
{
var changes = await new QueryLocalChanges(repo).GetResultAsync().ConfigureAwait(false);
try
{
foreach (var c in changes)
{
if (c.WorkTree == Models.ChangeState.Untracked ||
if ((c.WorkTree == Models.ChangeState.Untracked && includeUntracked) ||
c.WorkTree == Models.ChangeState.Added ||
c.Index == Models.ChangeState.Added ||
c.Index == Models.ChangeState.Renamed)
Expand Down
1 change: 1 addition & 0 deletions src/Resources/Locales/en_US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
<x:String x:Key="Text.Discard.All" xml:space="preserve">All local changes in working copy.</x:String>
<x:String x:Key="Text.Discard.Changes" xml:space="preserve">Changes:</x:String>
<x:String x:Key="Text.Discard.IncludeIgnored" xml:space="preserve">Include ignored files</x:String>
<x:String x:Key="Text.Discard.IncludeUntracked" xml:space="preserve">Include untracked files</x:String>
<x:String x:Key="Text.Discard.Total" xml:space="preserve">{0} changes will be discarded</x:String>
<x:String x:Key="Text.Discard.Warning" xml:space="preserve">You can't undo this action!!!</x:String>
<x:String x:Key="Text.EditRepositoryNode.Bookmark" xml:space="preserve">Bookmark:</x:String>
Expand Down
8 changes: 7 additions & 1 deletion src/ViewModels/Discard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ public bool IncludeIgnored
get;
set;
} = false;

public bool IncludeUntracked
{
get;
set;
} = false;
}

public class DiscardSingleFile
Expand Down Expand Up @@ -65,7 +71,7 @@ public override async Task<bool> Sure()
Use(log);

if (Mode is DiscardAllMode all)
await Commands.Discard.AllAsync(_repo.FullPath, all.IncludeIgnored, log);
await Commands.Discard.AllAsync(_repo.FullPath, all.IncludeIgnored, all.IncludeUntracked, log);
else
await Commands.Discard.ChangesAsync(_repo.FullPath, _changes, log);

Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/Pull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public override async Task<bool> Sure()
{
if (DiscardLocalChanges)
{
await Commands.Discard.AllAsync(_repo.FullPath, false, log);
await Commands.Discard.AllAsync(_repo.FullPath, false, true, log);
}
else
{
Expand Down
6 changes: 5 additions & 1 deletion src/Views/Discard.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ContentControl Margin="0,16,0,8" Content="{Binding Mode}">
<ContentControl.DataTemplates>
<DataTemplate DataType="vm:DiscardAllMode">
<Grid RowDefinitions="32,32" ColumnDefinitions="120,*">
<Grid RowDefinitions="32,32,32" ColumnDefinitions="120,*">
<TextBlock Grid.Row="0" Grid.Column="0"
Margin="0,0,8,0"
HorizontalAlignment="Right"
Expand All @@ -35,6 +35,10 @@
<CheckBox Grid.Row="1" Grid.Column="1"
Content="{DynamicResource Text.Discard.IncludeIgnored}"
IsChecked="{Binding IncludeIgnored, Mode=TwoWay}"/>

<CheckBox Grid.Row="2" Grid.Column="1"
Content="{DynamicResource Text.Discard.IncludeUntracked}"
IsChecked="{Binding IncludeUntracked, Mode=TwoWay}"/>
</Grid>
</DataTemplate>

Expand Down
Loading