From 506af959633d94f1fa054188e9b1cc85323f677a Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 8 Apr 2025 20:00:42 +0800 Subject: [PATCH] enhance: new confirm empty commit dialog (#1143) Signed-off-by: leo --- src/Resources/Locales/de_DE.axaml | 1 - src/Resources/Locales/en_US.axaml | 4 +- src/Resources/Locales/es_ES.axaml | 1 - src/Resources/Locales/fr_FR.axaml | 1 - src/Resources/Locales/it_IT.axaml | 1 - src/Resources/Locales/ja_JP.axaml | 1 - src/Resources/Locales/pt_BR.axaml | 1 - src/Resources/Locales/ru_RU.axaml | 1 - src/Resources/Locales/zh_CN.axaml | 4 +- src/Resources/Locales/zh_TW.axaml | 4 +- src/ViewModels/ConfirmEmptyCommit.cs | 31 ++++++++++++ src/ViewModels/WorkingCopy.cs | 7 ++- src/Views/ConfirmEmptyCommit.axaml | 72 +++++++++++++++++++++++++++ src/Views/ConfirmEmptyCommit.axaml.cs | 29 +++++++++++ 14 files changed, 144 insertions(+), 14 deletions(-) create mode 100644 src/ViewModels/ConfirmEmptyCommit.cs create mode 100644 src/Views/ConfirmEmptyCommit.axaml create mode 100644 src/Views/ConfirmEmptyCommit.axaml.cs diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 276f44e8..25b54c60 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -713,7 +713,6 @@ Klick-Ereignis auslösen Commit (Bearbeitung) Alle Änderungen stagen und committen - Leerer Commit erkannt! Fortfahren (--allow-empty)? KONFLIKTE ERKANNT DATEI KONFLIKTE GELÖST NICHT-VERFOLGTE DATEIEN INKLUDIEREN diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 97b2a832..8645cd96 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -177,6 +177,9 @@ Workspaces Color Restore tabs on startup + Empty commit detected! Do you want to continue (--allow-empty) or stage all then commit? + CONTINUE + STAGE ALL & COMMIT Conventional Commit Helper Breaking Change: Closed Issue: @@ -721,7 +724,6 @@ 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 INCLUDE UNTRACKED FILES diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index e6968560..e2af0860 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -724,7 +724,6 @@ Activar evento de clic Commit (Editar) Stagear todos los cambios y commit - ¡Commit vacío detectado! ¿Quieres continuar (--allow-empty)? CONFLICTOS DETECTADOS LOS CONFLICTOS DE ARCHIVOS ESTÁN RESUELTOS INCLUIR ARCHIVOS NO RASTREADOS diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index ac2ed8b8..83d590f5 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -726,7 +726,6 @@ Trigger click event Commit (Modifier) Indexer tous les changements et commit - Un commit vide a été détecté ! Voulez-vous continuer (--allow-empty) ? CONFLITS DÉTECTÉS LES CONFLITS DE FICHIER SONT RÉSOLUS INCLURE LES FICHIERS NON-SUIVIS diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index 95647101..59bf3028 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -723,7 +723,6 @@ Attiva evento click Commit (Modifica) Stage di tutte le modifiche e fai il commit - Trovato un commit vuoto! Vuoi continuare (--allow-empty)? CONFLITTI RILEVATI CONFLITTI NEI FILE RISOLTI INCLUDI FILE NON TRACCIATI diff --git a/src/Resources/Locales/ja_JP.axaml b/src/Resources/Locales/ja_JP.axaml index 91cefbac..fe643b5e 100644 --- a/src/Resources/Locales/ja_JP.axaml +++ b/src/Resources/Locales/ja_JP.axaml @@ -722,7 +722,6 @@ クリックイベントをトリガー コミット (Edit) すべての変更をステージしてコミット - 空のコミットが検出されました。続行しますか? (--allow-empty) 競合が検出されました ファイルの競合は解決されました 追跡されていないファイルを含める diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index 09b78c31..3caac3cc 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -657,7 +657,6 @@ Modelo/Históricos Acionar evento de clique Preparar todas as mudanças e commitar - Commit vazio detectado! Deseja continuar (--allow-empty)? CONFLITOS DETECTADOS CONFLITOS DE ARQUIVO RESOLVIDOS INCLUIR ARQUIVOS NÃO RASTREADOS diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index e778af86..b26532ae 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -725,7 +725,6 @@ Запустить событие щелчка Зафиксировать (Редактировать) Подготовить все изменения и зафиксировать - Обнаружена пустая ревизия! Вы хотите продолжить (--allow-empty)? ОБНАРУЖЕНЫ КОНФЛИКТЫ КОНФЛИКТЫ ФАЙЛОВ РАЗРЕШЕНЫ ВКЛЮЧИТЬ НЕОТСЛЕЖИВАЕМЫЕ ФАЙЛЫ diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index c1cbcc77..a2bde6f8 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -181,6 +181,9 @@ 工作区 颜色 启动时恢复打开的仓库 + 提交未包含变更文件!是否继续(--allow-empty)或是自动暂存所有变更并提交? + 确认继续 + 自动暂存并提交 规范化提交信息生成 破坏性更新: 关闭的ISSUE: @@ -726,7 +729,6 @@ 提交(修改原始提交) 自动暂存所有变更并提交 当前有 {0} 个文件在暂存区中,但仅显示了 {1} 个文件({2} 个文件被过滤掉了),是否继续提交? - 提交未包含变更文件!是否继续(--allow-empty)? 检测到冲突 文件冲突已解决 显示未跟踪文件 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 34dac155..571f9376 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -181,6 +181,9 @@ 工作區 顏色 啟動時還原上次開啟的存放庫 + 未包含任何檔案變更! 您是否仍要提交 (--allow-empty)或者自動暫存全部變更並提交? + 确认继续 + 自动暂存并提交 產生約定式提交訊息 破壞性變更: 關閉的 Issue: @@ -725,7 +728,6 @@ 提交 (修改原始提交) 自動暫存全部變更並提交 您已暫存 {0} 檔案,但只顯示 {1} 檔案 ({2} 檔案被篩選器隱藏)。您要繼續嗎? - 未包含任何檔案變更! 您是否仍要提交 (--allow-empty)? 檢測到衝突 檔案衝突已解決 顯示未追蹤檔案 diff --git a/src/ViewModels/ConfirmEmptyCommit.cs b/src/ViewModels/ConfirmEmptyCommit.cs new file mode 100644 index 00000000..71d1f00c --- /dev/null +++ b/src/ViewModels/ConfirmEmptyCommit.cs @@ -0,0 +1,31 @@ +using System; + +namespace SourceGit.ViewModels +{ + public class ConfirmEmptyCommit + { + public bool HasLocalChanges + { + get; + private set; + } + + public ConfirmEmptyCommit(bool hasLocalChanges, Action onSure) + { + HasLocalChanges = hasLocalChanges; + _onSure = onSure; + } + + public void StageAllThenCommit() + { + _onSure?.Invoke(true); + } + + public void Continue() + { + _onSure?.Invoke(false); + } + + private Action _onSure; + } +} diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 784328cc..83813f39 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -1679,12 +1679,11 @@ namespace SourceGit.ViewModels { if ((autoStage && _count == 0) || (!autoStage && _staged.Count == 0)) { - var confirmMessage = App.Text("WorkingCopy.ConfirmCommitWithoutFiles"); - App.OpenDialog(new Views.ConfirmCommit() + App.OpenDialog(new Views.ConfirmEmptyCommit() { - DataContext = new ConfirmCommit(confirmMessage, () => + DataContext = new ConfirmEmptyCommit(_count > 0, stageAll => { - DoCommit(autoStage, autoPush, true, confirmWithFilter); + DoCommit(stageAll, autoPush, true, confirmWithFilter); }) }); diff --git a/src/Views/ConfirmEmptyCommit.axaml b/src/Views/ConfirmEmptyCommit.axaml new file mode 100644 index 00000000..ba51212b --- /dev/null +++ b/src/Views/ConfirmEmptyCommit.axaml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + +