From 4924e960bffc2343f809d3ad93027e6080cf4dad Mon Sep 17 00:00:00 2001 From: "Dmitrij D. Czarkoff" Date: Sun, 10 Nov 2024 04:51:15 +0000 Subject: [PATCH] feature: allow merging tags into branches (#671) Adds "Merge {tag} into {branch}" menu item to tag menu in histories. The rest is handled by already existing merge code. --- 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/pt_BR.axaml | 1 + src/Resources/Locales/ru_RU.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/Histories.cs | 17 +++++++++++++++-- 9 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index c99acf77..d1f43695 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -627,6 +627,7 @@ Tag-Namen kopieren Tag-Nachricht kopieren Lösche ${0}$... + Merge ${0}$ in ${1}$ hinein... Pushe ${0}$... URL: Submodule aktualisieren diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 166ad3ab..3803bd39 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -633,6 +633,7 @@ Copy Tag Name Copy Tag Message Delete ${0}$... + Merge ${0}$ into ${1}$... Push ${0}$... URL: Update Submodules diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index 43296be0..8ae1d789 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -631,6 +631,7 @@ Copiar Nombre de la Etiqueta Copiar Mensaje de la Etiqueta Eliminar ${0}$... + Merge ${0}$ en ${1}$... Push ${0}$... URL: Actualizar Submódulos diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index f50b8f34..043e8f97 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -551,6 +551,7 @@ OK Copy Tag Name Delete ${0}$... + Fusionner ${0}$ dans ${1}$... Push ${0}$... URL : Actualiser les sous-modules diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index d7f4170d..61ded334 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -661,6 +661,7 @@ Copiar Nome da Tag Copiar mensage da Tag Excluir ${0}$... + Mesclar ${0}$ em ${1}$... Enviar ${0}$... Todos os submódulos Inicializar conforme necessário diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index cfca1cc8..3ea6a922 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -637,6 +637,7 @@ Копировать имя метки Копировать сообщение с метки Удалить ${0}$... + Слить ${0}$ в ${1}$... Выложить ${0}$... Сетевой адрес: Обновление подмодулей diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 5632a3ef..3df54899 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -636,6 +636,7 @@ 复制标签名 复制标签信息 删除 ${0}$... + 合并 ${0}$ 到 ${1}$... 推送 ${0}$... 仓库地址 : 更新子模块 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 229a5fdb..4dcb31aa 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -636,6 +636,7 @@ 複製標籤名稱 複製標籤訊息 刪除 ${0}$... + 合併 ${0}$ 到 ${1}$... 推送 ${0}$... 存放庫網址: 更新子模組 diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index 688dab87..47736a06 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -365,7 +365,7 @@ namespace SourceGit.ViewModels if (tags.Count > 0) { foreach (var tag in tags) - FillTagMenu(menu, tag); + FillTagMenu(menu, tag, current, commit.IsMerged); menu.Items.Add(new MenuItem() { Header = "-" }); } @@ -893,7 +893,7 @@ namespace SourceGit.ViewModels menu.Items.Add(submenu); } - private void FillTagMenu(ContextMenu menu, Models.Tag tag) + private void FillTagMenu(ContextMenu menu, Models.Tag tag, Models.Branch current, bool merged) { var submenu = new MenuItem(); submenu.Header = tag.Name; @@ -912,6 +912,19 @@ namespace SourceGit.ViewModels }; submenu.Items.Add(push); + var merge = new MenuItem(); + merge.Header = new Views.NameHighlightedTextBlock("TagCM.Merge", tag.Name, current.Name); + merge.Icon = App.CreateMenuIcon("Icons.Merge"); + merge.IsEnabled = !merged; + merge.Click += (_, e) => + { + if (PopupHost.CanCreatePopup()) + PopupHost.ShowPopup(new Merge(_repo, tag.Name, current.Name)); + e.Handled = true; + }; + submenu.Items.Add(merge); + submenu.Items.Add(new MenuItem() { Header = "-" }); + var delete = new MenuItem(); delete.Header = new Views.NameHighlightedTextBlock("TagCM.Delete", tag.Name); delete.Icon = App.CreateMenuIcon("Icons.Clear");