diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index 2a475acd..9c3c7a9a 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -637,6 +637,7 @@
Template/Histories
Trigger click event
Stage all changes and commit
+ Empty commit detected! Do you want to continue (--allow-empty)?
CONFLICTS DETECTED
FILE CONFLICTS ARE RESOLVED
INCLUDE UNTRACKED FILES
diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml
index e8346fa3..d17aab23 100644
--- a/src/Resources/Locales/zh_CN.axaml
+++ b/src/Resources/Locales/zh_CN.axaml
@@ -635,6 +635,7 @@
历史输入/模板
触发点击事件
自动暂存所有变更并提交
+ 提交未包含变更文件!是否继续(--allow-empty)?
检测到冲突
文件冲突已解决
显示未跟踪文件
diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml
index fb6489cf..715f0b95 100644
--- a/src/Resources/Locales/zh_TW.axaml
+++ b/src/Resources/Locales/zh_TW.axaml
@@ -640,6 +640,7 @@
歷史輸入/範本
觸發點擊事件
自動暫存全部變更並提交
+ 提交未包含變更檔案!是否繼續(--allow-empty)?
檢測到衝突
檔案衝突已解決
顯示未追蹤檔案
diff --git a/src/ViewModels/ConfirmCommitWithoutFiles.cs b/src/ViewModels/ConfirmCommitWithoutFiles.cs
new file mode 100644
index 00000000..3249fba8
--- /dev/null
+++ b/src/ViewModels/ConfirmCommitWithoutFiles.cs
@@ -0,0 +1,19 @@
+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 26b81de6..808a7ef6 100644
--- a/src/ViewModels/WorkingCopy.cs
+++ b/src/ViewModels/WorkingCopy.cs
@@ -410,17 +410,22 @@ namespace SourceGit.ViewModels
public void Commit()
{
- DoCommit(false, false);
+ DoCommit(false, false, false);
}
public void CommitWithAutoStage()
{
- DoCommit(true, false);
+ DoCommit(true, false, false);
}
public void CommitWithPush()
{
- DoCommit(false, true);
+ DoCommit(false, true, false);
+ }
+
+ public void CommitWithoutFiles(bool autoPush)
+ {
+ DoCommit(false, autoPush, true);
}
public ContextMenu CreateContextMenuForUnstagedChanges()
@@ -1268,7 +1273,7 @@ namespace SourceGit.ViewModels
_repo.SetWatcherEnabled(true);
}
- private void DoCommit(bool autoStage, bool autoPush)
+ private void DoCommit(bool autoStage, bool autoPush, bool allowEmpty)
{
if (!PopupHost.CanCreatePopup())
{
@@ -1282,23 +1287,16 @@ namespace SourceGit.ViewModels
return;
}
- if (!_useAmend)
+ if (!_useAmend && !allowEmpty)
{
- if (autoStage)
+ if ((autoStage && _count == 0) || (!autoStage && _staged.Count == 0))
{
- if (_count == 0)
+ App.OpenDialog(new Views.ConfirmCommitWithoutFiles()
{
- App.RaiseException(_repo.FullPath, "No files added to commit!");
- return;
- }
- }
- else
- {
- if (_staged.Count == 0)
- {
- App.RaiseException(_repo.FullPath, "No files added to commit!");
- return;
- }
+ DataContext = new ConfirmCommitWithoutFiles(this, autoPush)
+ });
+
+ return;
}
}
@@ -1313,7 +1311,7 @@ namespace SourceGit.ViewModels
succ = new Commands.Add(_repo.FullPath, _repo.IncludeUntracked).Exec();
if (succ)
- succ = new Commands.Commit(_repo.FullPath, _commitMessage, _useAmend).Exec();
+ succ = new Commands.Commit(_repo.FullPath, _commitMessage, _useAmend, true).Exec();
Dispatcher.UIThread.Post(() =>
{
diff --git a/src/Views/ConfirmCommitWithoutFiles.axaml b/src/Views/ConfirmCommitWithoutFiles.axaml
new file mode 100644
index 00000000..0b457531
--- /dev/null
+++ b/src/Views/ConfirmCommitWithoutFiles.axaml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Views/ConfirmCommitWithoutFiles.axaml.cs b/src/Views/ConfirmCommitWithoutFiles.axaml.cs
new file mode 100644
index 00000000..0be18902
--- /dev/null
+++ b/src/Views/ConfirmCommitWithoutFiles.axaml.cs
@@ -0,0 +1,33 @@
+using Avalonia.Input;
+using Avalonia.Interactivity;
+
+namespace SourceGit.Views
+{
+ public partial class ConfirmCommitWithoutFiles : ChromelessWindow
+ {
+ public ConfirmCommitWithoutFiles()
+ {
+ InitializeComponent();
+ }
+
+ private void BeginMoveWindow(object _, PointerPressedEventArgs e)
+ {
+ BeginMoveDrag(e);
+ }
+
+ private void Sure(object _1, RoutedEventArgs _2)
+ {
+ if (DataContext is ViewModels.ConfirmCommitWithoutFiles vm)
+ {
+ vm.Continue();
+ }
+
+ Close();
+ }
+
+ private void CloseWindow(object _1, RoutedEventArgs _2)
+ {
+ Close();
+ }
+ }
+}
diff --git a/src/Views/ConventionalCommitMessageBuilder.axaml b/src/Views/ConventionalCommitMessageBuilder.axaml
index 19174a6d..ab2ae37f 100644
--- a/src/Views/ConventionalCommitMessageBuilder.axaml
+++ b/src/Views/ConventionalCommitMessageBuilder.axaml
@@ -16,7 +16,7 @@
SizeToContent="Height"
CanResize="False"
WindowStartupLocation="CenterOwner">
-
+