diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index 5ff1e3a4..61140173 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -719,6 +719,7 @@
Trigger click event
Commit (Edit)
Stage all changes and commit
+ You have staged {0} file(s) but only {1} file(s) displayed ({2} files are filtered out). Do you want to continue?
Empty commit detected! Do you want to continue (--allow-empty)?
CONFLICTS DETECTED
FILE CONFLICTS ARE RESOLVED
diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml
index 8d2b4f1e..fec5c780 100644
--- a/src/Resources/Locales/zh_CN.axaml
+++ b/src/Resources/Locales/zh_CN.axaml
@@ -723,6 +723,7 @@
触发点击事件
提交(修改原始提交)
自动暂存所有变更并提交
+ 当前有 {0} 个文件在暂存区中,但仅显示了 {1} 个文件({2} 个文件被过滤掉了),是否继续提交?
提交未包含变更文件!是否继续(--allow-empty)?
检测到冲突
文件冲突已解决
diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml
index 8e823f68..66bcc33a 100644
--- a/src/Resources/Locales/zh_TW.axaml
+++ b/src/Resources/Locales/zh_TW.axaml
@@ -722,6 +722,7 @@
觸發點擊事件
提交 (修改原始提交)
自動暫存全部變更並提交
+ 您已暫存 {0} 檔案,但只顯示 {1} 檔案 ({2} 檔案被篩選器隱藏)。您要繼續嗎?
未包含任何檔案變更! 您是否仍要提交 (--allow-empty)?
檢測到衝突
檔案衝突已解決
diff --git a/src/ViewModels/ConfirmCommit.cs b/src/ViewModels/ConfirmCommit.cs
new file mode 100644
index 00000000..cea56948
--- /dev/null
+++ b/src/ViewModels/ConfirmCommit.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace SourceGit.ViewModels
+{
+ public class ConfirmCommit
+ {
+ public string Message
+ {
+ get;
+ private set;
+ }
+
+ public ConfirmCommit(string message, Action onSure)
+ {
+ Message = message;
+ _onSure = onSure;
+ }
+
+ public void Continue()
+ {
+ _onSure?.Invoke();
+ }
+
+ private Action _onSure;
+ }
+}
diff --git a/src/ViewModels/ConfirmCommitWithoutFiles.cs b/src/ViewModels/ConfirmCommitWithoutFiles.cs
deleted file mode 100644
index 3249fba8..00000000
--- a/src/ViewModels/ConfirmCommitWithoutFiles.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace SourceGit.ViewModels
-{
- public class ConfirmCommitWithoutFiles
- {
- public ConfirmCommitWithoutFiles(WorkingCopy wc, bool autoPush)
- {
- _wc = wc;
- _autoPush = autoPush;
- }
-
- public void Continue()
- {
- _wc.CommitWithoutFiles(_autoPush);
- }
-
- private readonly WorkingCopy _wc;
- private bool _autoPush;
- }
-}
diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs
index 3e6f6fbd..a0933ea3 100644
--- a/src/ViewModels/WorkingCopy.cs
+++ b/src/ViewModels/WorkingCopy.cs
@@ -99,38 +99,23 @@ namespace SourceGit.ViewModels
}
}
- public string UnstagedFilter
+ public string Filter
{
- get => _unstagedFilter;
+ get => _filter;
set
{
- if (SetProperty(ref _unstagedFilter, value))
+ if (SetProperty(ref _filter, value))
{
if (_isLoadingData)
return;
- VisibleUnstaged = GetVisibleChanges(_unstaged, _unstagedFilter);
+ VisibleUnstaged = GetVisibleChanges(_unstaged);
+ VisibleStaged = GetVisibleChanges(_staged);
SelectedUnstaged = [];
}
}
}
- public string StagedFilter
- {
- get => _stagedFilter;
- set
- {
- if (SetProperty(ref _stagedFilter, value))
- {
- if (_isLoadingData)
- return;
-
- VisibleStaged = GetVisibleChanges(_staged, _stagedFilter);
- SelectedStaged = [];
- }
- }
- }
-
public List Unstaged
{
get => _unstaged;
@@ -294,7 +279,7 @@ namespace SourceGit.ViewModels
}
}
- var visibleUnstaged = GetVisibleChanges(unstaged, _unstagedFilter);
+ var visibleUnstaged = GetVisibleChanges(unstaged);
var selectedUnstaged = new List();
foreach (var c in visibleUnstaged)
{
@@ -304,7 +289,7 @@ namespace SourceGit.ViewModels
var staged = GetStagedChanges();
- var visibleStaged = GetVisibleChanges(staged, _stagedFilter);
+ var visibleStaged = GetVisibleChanges(staged);
var selectedStaged = new List();
foreach (var c in visibleStaged)
{
@@ -374,14 +359,9 @@ namespace SourceGit.ViewModels
_repo.ShowPopup(new Discard(_repo, changes));
}
- public void ClearUnstagedFilter()
+ public void ClearFilter()
{
- UnstagedFilter = string.Empty;
- }
-
- public void ClearStagedFilter()
- {
- StagedFilter = string.Empty;
+ Filter = string.Empty;
}
public async void UseTheirs(List changes)
@@ -571,11 +551,6 @@ namespace SourceGit.ViewModels
DoCommit(false, true, false);
}
- public void CommitWithoutFiles(bool autoPush)
- {
- DoCommit(false, autoPush, true);
- }
-
public ContextMenu CreateContextMenuForUnstagedChanges()
{
if (_selectedUnstaged == null || _selectedUnstaged.Count == 0)
@@ -1505,16 +1480,16 @@ namespace SourceGit.ViewModels
return menu;
}
- private List GetVisibleChanges(List changes, string filter)
+ private List GetVisibleChanges(List changes)
{
- if (string.IsNullOrEmpty(filter))
+ if (string.IsNullOrEmpty(_filter))
return changes;
var visible = new List();
foreach (var c in changes)
{
- if (c.Path.Contains(filter, StringComparison.OrdinalIgnoreCase))
+ if (c.Path.Contains(_filter, StringComparison.OrdinalIgnoreCase))
visible.Add(c);
}
@@ -1675,7 +1650,7 @@ namespace SourceGit.ViewModels
DetailContext = new DiffContext(_repo.FullPath, new Models.DiffOption(change, isUnstaged), _detailContext as DiffContext);
}
- private void DoCommit(bool autoStage, bool autoPush, bool allowEmpty)
+ private void DoCommit(bool autoStage, bool autoPush, bool allowEmpty = false, bool confirmWithFilter = false)
{
if (!_repo.CanCreatePopup())
{
@@ -1683,10 +1658,17 @@ namespace SourceGit.ViewModels
return;
}
- if (!string.IsNullOrEmpty(_stagedFilter))
+ if (!string.IsNullOrEmpty(_filter) && _staged.Count > _visibleStaged.Count && !confirmWithFilter)
{
- // FIXME - make this a proper warning message-box "Staged-area filter will not be applied to commit. Continue?" Yes/No
- App.RaiseException(_repo.FullPath, "Committing with staged-area filter applied is NOT allowed!");
+ var confirmMessage = App.Text("WorkingCopy.ConfirmCommitWithFilter", _staged.Count, _visibleStaged.Count, _staged.Count - _visibleStaged.Count);
+ App.OpenDialog(new Views.ConfirmCommit()
+ {
+ DataContext = new ConfirmCommit(confirmMessage, () =>
+ {
+ DoCommit(autoStage, autoPush, allowEmpty, true);
+ })
+ });
+
return;
}
@@ -1700,9 +1682,13 @@ namespace SourceGit.ViewModels
{
if ((autoStage && _count == 0) || (!autoStage && _staged.Count == 0))
{
- App.OpenDialog(new Views.ConfirmCommitWithoutFiles()
+ var confirmMessage = App.Text("WorkingCopy.ConfirmCommitWithoutFiles");
+ App.OpenDialog(new Views.ConfirmCommit()
{
- DataContext = new ConfirmCommitWithoutFiles(this, autoPush)
+ DataContext = new ConfirmCommit(confirmMessage, () =>
+ {
+ DoCommit(autoStage, autoPush, true, confirmWithFilter);
+ })
});
return;
@@ -1774,8 +1760,7 @@ namespace SourceGit.ViewModels
private List _selectedStaged = [];
private int _count = 0;
private object _detailContext = null;
- private string _unstagedFilter = string.Empty;
- private string _stagedFilter = string.Empty;
+ private string _filter = string.Empty;
private string _commitMessage = string.Empty;
private bool _hasUnsolvedConflicts = false;
diff --git a/src/Views/ConfirmCommitWithoutFiles.axaml b/src/Views/ConfirmCommit.axaml
similarity index 92%
rename from src/Views/ConfirmCommitWithoutFiles.axaml
rename to src/Views/ConfirmCommit.axaml
index 4c9fd1c8..77bbdb30 100644
--- a/src/Views/ConfirmCommitWithoutFiles.axaml
+++ b/src/Views/ConfirmCommit.axaml
@@ -5,8 +5,8 @@
xmlns:v="using:SourceGit.Views"
xmlns:vm="using:SourceGit.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
- x:Class="SourceGit.Views.ConfirmCommitWithoutFiles"
- x:DataType="vm:ConfirmCommitWithoutFiles"
+ x:Class="SourceGit.Views.ConfirmCommit"
+ x:DataType="vm:ConfirmCommit"
x:Name="ThisControl"
Icon="/App.ico"
Title="{DynamicResource Text.Warn}"
@@ -38,7 +38,7 @@
-
+
diff --git a/src/Views/ConfirmCommitWithoutFiles.axaml.cs b/src/Views/ConfirmCommit.axaml.cs
similarity index 57%
rename from src/Views/ConfirmCommitWithoutFiles.axaml.cs
rename to src/Views/ConfirmCommit.axaml.cs
index 342600fc..1cf770cb 100644
--- a/src/Views/ConfirmCommitWithoutFiles.axaml.cs
+++ b/src/Views/ConfirmCommit.axaml.cs
@@ -2,20 +2,16 @@ using Avalonia.Interactivity;
namespace SourceGit.Views
{
- public partial class ConfirmCommitWithoutFiles : ChromelessWindow
+ public partial class ConfirmCommit : ChromelessWindow
{
- public ConfirmCommitWithoutFiles()
+ public ConfirmCommit()
{
InitializeComponent();
}
private void Sure(object _1, RoutedEventArgs _2)
{
- if (DataContext is ViewModels.ConfirmCommitWithoutFiles vm)
- {
- vm.Continue();
- }
-
+ (DataContext as ViewModels.ConfirmCommit)?.Continue();
Close();
}
diff --git a/src/Views/WorkingCopy.axaml b/src/Views/WorkingCopy.axaml
index 6af2b448..94dd0c30 100644
--- a/src/Views/WorkingCopy.axaml
+++ b/src/Views/WorkingCopy.axaml
@@ -19,13 +19,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -75,40 +108,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -155,41 +156,9 @@
ViewMode="{Binding Source={x:Static vm:Preferences.Instance}, Path=StagedChangeViewMode, Mode=TwoWay}"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-