From 3dc4bf50715ce8f5de88c339cd9f1fa3b7e0f62b Mon Sep 17 00:00:00 2001 From: nelson870708 Date: Wed, 12 Nov 2025 20:34:01 +0800 Subject: [PATCH] feat: add merge strategy option to merge command and UI --- src/Commands/Merge.cs | 4 +++- src/Resources/Locales/de_DE.axaml | 1 + src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/es_ES.axaml | 1 + src/Resources/Locales/fr_FR.axaml | 1 + src/Resources/Locales/id_ID.axaml | 1 + src/Resources/Locales/it_IT.axaml | 1 + src/Resources/Locales/ja_JP.axaml | 1 + src/Resources/Locales/ko_KR.axaml | 1 + src/Resources/Locales/pt_BR.axaml | 1 + src/Resources/Locales/ru_RU.axaml | 1 + src/Resources/Locales/ta_IN.axaml | 1 + src/Resources/Locales/uk_UA.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/Merge.cs | 13 ++++++++++++- src/Views/Merge.axaml | 23 +++++++++++++++++++++-- 17 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/Commands/Merge.cs b/src/Commands/Merge.cs index bd11b5779..065c4aa43 100644 --- a/src/Commands/Merge.cs +++ b/src/Commands/Merge.cs @@ -5,7 +5,7 @@ namespace SourceGit.Commands { public class Merge : Command { - public Merge(string repo, string source, string mode, bool edit) + public Merge(string repo, string source, string mode, bool edit, string strategy) { WorkingDirectory = repo; Context = repo; @@ -14,6 +14,8 @@ public Merge(string repo, string source, string mode, bool edit) var builder = new StringBuilder(); builder.Append("merge --progress "); builder.Append(edit ? "--edit " : "--no-edit "); + if (!string.IsNullOrEmpty(strategy)) + builder.Append("--strategy=").Append(strategy).Append(' '); builder.Append(source); builder.Append(' '); builder.Append(mode); diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 2d167da69..eaae58468 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -529,6 +529,7 @@ Merge-Nachricht anpassen Ziel-Branch: Merge Option: + Strategie: Quelle: Merge (mehrere) Alle Änderungen committen diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 76fcb9564..03817213c 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -524,6 +524,7 @@ Customize merge message Into: Merge Option: + Strategy: Source: Merge (Multiple) Commit all changes diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index e07557557..85bd10ae2 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -528,6 +528,7 @@ Personalizar mensaje de merge En: Opción de Merge: + Estrategia: Rama Fuente: Merge (Multiplo) Commit todos los cambios diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index 1ec5a1ab8..958531e1c 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -526,6 +526,7 @@ Personnaliser le message de fusion Dans : Option de merge: + Stratégie: Source: Fusionner (Plusieurs) Commit tous les changement diff --git a/src/Resources/Locales/id_ID.axaml b/src/Resources/Locales/id_ID.axaml index e6f101f22..26df70614 100644 --- a/src/Resources/Locales/id_ID.axaml +++ b/src/Resources/Locales/id_ID.axaml @@ -503,6 +503,7 @@ Sesuaikan pesan merge Ke: Opsi Merge: + Strategi: Sumber: Merge (Beberapa) Commit semua perubahan diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index 51ac07059..9e9d8259e 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -490,6 +490,7 @@ Personalizza messaggio di merge In: Opzione di Unione: + Strategia: Sorgente: Unione (multipla) Commit di tutte le modifiche diff --git a/src/Resources/Locales/ja_JP.axaml b/src/Resources/Locales/ja_JP.axaml index e6a53aa8c..41a4537b7 100644 --- a/src/Resources/Locales/ja_JP.axaml +++ b/src/Resources/Locales/ja_JP.axaml @@ -386,6 +386,7 @@ ブランチのマージ 宛先: マージオプション: + マージ戦略: ソースブランチ: マージ (複数) すべての変更をコミット diff --git a/src/Resources/Locales/ko_KR.axaml b/src/Resources/Locales/ko_KR.axaml index 7a84f3504..2749367e2 100644 --- a/src/Resources/Locales/ko_KR.axaml +++ b/src/Resources/Locales/ko_KR.axaml @@ -505,6 +505,7 @@ 병합 메시지 수정 대상: 병합 옵션: + 전략: 소스: 병합 (다중) 모든 변경 사항 커밋 diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index 972c5049d..2c6e891ae 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -357,6 +357,7 @@ Mesclar Ramo Para: Opção de Mesclagem: + Estratégia: Mover nó do repositório Selecionar nó pai para: Nome: diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index 2ca0fc463..706911a64 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -525,6 +525,7 @@ Изменить сообщение слияния В: Опции слияния: + Стратегия: Источник: Влить несколько веток Зафиксировать все изменения diff --git a/src/Resources/Locales/ta_IN.axaml b/src/Resources/Locales/ta_IN.axaml index a88491256..208ac2a68 100644 --- a/src/Resources/Locales/ta_IN.axaml +++ b/src/Resources/Locales/ta_IN.axaml @@ -386,6 +386,7 @@ கிளையை ஒன்றிணை Into: இணைப்பு விருப்பம்: + சூழ்ச்சிமுறை: இதனுள்: ஒன்றிணை (பல) அனைத்து மாற்றங்களையும் உறுதிமொழி diff --git a/src/Resources/Locales/uk_UA.axaml b/src/Resources/Locales/uk_UA.axaml index aab8114a4..5e5f748c4 100644 --- a/src/Resources/Locales/uk_UA.axaml +++ b/src/Resources/Locales/uk_UA.axaml @@ -391,6 +391,7 @@ Злиття гілки В: Опція злиття: + Стратегія: Джерело: Злиття (Кілька) Закомітити всі зміни diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 24c7c32bc..5cdd475f0 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -528,6 +528,7 @@ 编辑合并信息 目标分支 : 合并方式 : + 合并策略 : 合并目标 : 合并(多目标) 提交变化 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 436b594ad..f5a7af074 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -528,6 +528,7 @@ 編輯合併訊息 目標分支: 合併方式: + 合併策略: 合併來源: 合併 (多個來源) 提交變更 diff --git a/src/ViewModels/Merge.cs b/src/ViewModels/Merge.cs index 5228c790a..d8dba36bf 100644 --- a/src/ViewModels/Merge.cs +++ b/src/ViewModels/Merge.cs @@ -20,6 +20,12 @@ public Models.MergeMode Mode set; } + public Models.MergeStrategy Strategy + { + get; + set; + } = Models.MergeStrategy.ForMultiple[0]; + public bool Edit { get; @@ -65,7 +71,12 @@ public override async Task Sure() var log = _repo.CreateLog($"Merging '{_sourceName}' into '{Into}'"); Use(log); - await new Commands.Merge(_repo.FullPath, _sourceName, Mode.Arg, Edit) + await new Commands.Merge( + _repo.FullPath, + _sourceName, + Mode.Arg, + Edit, + Strategy?.Arg ?? string.Empty) .Use(log) .ExecAsync(); diff --git a/src/Views/Merge.axaml b/src/Views/Merge.axaml index 2fa000157..023946bf4 100644 --- a/src/Views/Merge.axaml +++ b/src/Views/Merge.axaml @@ -12,7 +12,7 @@ - + - + + + + + + + + + + + +