From 718d2ad16c4b65727a1396054a1063bbd19ac61f Mon Sep 17 00:00:00 2001 From: Mutzi Muszkal Date: Fri, 10 Oct 2025 13:41:03 -0400 Subject: [PATCH] Add custom branch name option for push operations --- src/Resources/Locales/de_DE.axaml | 2 + src/Resources/Locales/en_US.axaml | 2 + src/Resources/Locales/es_ES.axaml | 2 + src/Resources/Locales/fr_FR.axaml | 2 + src/Resources/Locales/it_IT.axaml | 2 + src/Resources/Locales/ja_JP.axaml | 2 + src/Resources/Locales/pt_BR.axaml | 2 + src/Resources/Locales/ru_RU.axaml | 2 + src/Resources/Locales/ta_IN.axaml | 2 + src/Resources/Locales/uk_UA.axaml | 2 + src/Resources/Locales/zh_CN.axaml | 2 + src/Resources/Locales/zh_TW.axaml | 2 + src/ViewModels/Push.cs | 75 ++++++++++++++++++++++++++++--- src/Views/Push.axaml | 69 ++++++++++++++++------------ 14 files changed, 134 insertions(+), 34 deletions(-) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index b6a302e26..7b11d6898 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -631,6 +631,8 @@ Revision zu Remote-Branch pushen Push Remote-Branch: + Benutzerdefinierten Branch-Namen verwenden + Benutzerdefinierten Branch-Namen eingeben... Remote-Branch verfolgen Alle Tags pushen Tag zum Remote pushen diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 7884a14d2..6334c6cde 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -631,6 +631,8 @@ Push Revision To Remote Push Changes To Remote Remote Branch: + Use custom branch name + Enter custom branch name... Set as tracking branch Push all tags Push Tag To Remote diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index 30e793376..8ebb30f42 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -635,6 +635,8 @@ Push Revisión al Remoto Push Cambios al Remoto Rama Remota: + Usar nombre de rama personalizado + Ingrese nombre de rama personalizado... Establecer como rama de seguimiento Push todas las etiquetas Push Etiqueta al Remoto diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index 32ae0e9f9..466d98d79 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -498,6 +498,8 @@ Dépôt distant : Pousser les changements vers le dépôt distant Branche distante : + Utiliser un nom de branche personnalisé + Saisir un nom de branche personnalisé... Définir comme branche de suivi Pousser tous les tags Pousser les tags vers le dépôt distant diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index 7d05b8c9f..1cf99769d 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -610,6 +610,8 @@ Invia Revisione Al Remoto Invia modifiche al remoto Branch Remoto: + Usa nome branch personalizzato + Inserisci nome branch personalizzato... Imposta come branch di tracciamento Invia tutti i tag Invia Tag al Remoto diff --git a/src/Resources/Locales/ja_JP.axaml b/src/Resources/Locales/ja_JP.axaml index 4698a5508..5db951efb 100644 --- a/src/Resources/Locales/ja_JP.axaml +++ b/src/Resources/Locales/ja_JP.axaml @@ -497,6 +497,8 @@ リモート: 変更をリモートにプッシュ リモート ブランチ: + カスタムブランチ名を使用 + カスタムブランチ名を入力... 追跡ブランチとして設定 すべてのタグをプッシュ リモートにタグをプッシュ diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index bc1f92ebe..7ed9e69f7 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -457,6 +457,8 @@ Remoto: Empurrar Alterações para o Remoto Branch Remoto: + Usar nome de branch personalizado + Digite o nome do branch personalizado... Definir como branch de rastreamento Empurrar todas as tags Empurrar Tag para o Remoto diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index 776bb7816..82b8abf9b 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -635,6 +635,8 @@ Выложить ревизию на удалёную Выложить изменения на внешний репозиторий Ветка внешнего репозитория: + Использовать пользовательское имя ветки + Введите пользовательское имя ветки... Отслеживать ветку Выложить все метки Выложить метку на внешний репозиторий diff --git a/src/Resources/Locales/ta_IN.axaml b/src/Resources/Locales/ta_IN.axaml index a29ccef34..e31c3919f 100644 --- a/src/Resources/Locales/ta_IN.axaml +++ b/src/Resources/Locales/ta_IN.axaml @@ -497,6 +497,8 @@ தொலை: மாற்றங்களை தொலைக்கு தள்ளு தொலை கிளை: + தனிப்பயன் கிளைப் பெயரைப் பயன்படுத்து + தனிப்பயன் கிளைப் பெயரை உள்ளிடவும்... கண்காணிப்பு கிளையாக அமை அனைத்து குறிச்சொற்களையும் தள்ளு தொலைக்கு குறிச்சொல்லை தள்ளு diff --git a/src/Resources/Locales/uk_UA.axaml b/src/Resources/Locales/uk_UA.axaml index 82e2a0c6f..670884773 100644 --- a/src/Resources/Locales/uk_UA.axaml +++ b/src/Resources/Locales/uk_UA.axaml @@ -502,6 +502,8 @@ Віддалене сховище: Надіслати зміни на віддалене сховище Віддалена гілка: + Використовувати користувацьку назву гілки + Введіть користувацьку назву гілки... Встановити як відстежувану гілку Надіслати всі теги Надіслати тег на віддалене сховище diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index cc3b04549..15a03ecc9 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -635,6 +635,8 @@ 推送指定修订到远程仓库 推送到远程仓库 远程分支 : + 使用自定义分支名称 + 输入自定义分支名称... 跟踪远程分支 同时推送标签 推送标签到远程仓库 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 14c7509cd..aa408a715 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -635,6 +635,8 @@ 推送修訂到遠端存放庫 推送到遠端存放庫 遠端分支: + 使用自訂分支名稱 + 輸入自訂分支名稱... 追蹤遠端分支 同時推送標籤 推送標籤到遠端存放庫 diff --git a/src/ViewModels/Push.cs b/src/ViewModels/Push.cs index 6b6857163..9834d65dc 100644 --- a/src/ViewModels/Push.cs +++ b/src/ViewModels/Push.cs @@ -57,7 +57,66 @@ public Models.Branch SelectedRemoteBranch set { if (SetProperty(ref _selectedRemoteBranch, value, true)) + { + if (value != null) + { + CustomRemoteBranchName = value.Name; + } + IsSetTrackOptionVisible = value != null && _selectedLocalBranch.Upstream != value.FullName; + } + } + } + + [Required(ErrorMessage = "Remote branch name is required!!!")] + public string CustomRemoteBranchName + { + get => _customRemoteBranchName; + set + { + if (SetProperty(ref _customRemoteBranchName, value, true)) + { + if (UseCustomBranchName) + { + var expectedUpstream = $"refs/remotes/{_selectedRemote.Name}/{value}"; + IsSetTrackOptionVisible = !string.IsNullOrEmpty(value) && + _selectedLocalBranch.Upstream != expectedUpstream; + } + } + } + } + + public bool UseCustomBranchName + { + get => _useCustomBranchName; + set + { + if (SetProperty(ref _useCustomBranchName, value)) + { + if (value) + { + // When switching to custom mode, pre-fill with the selected branch name if available + if (_selectedRemoteBranch != null && string.IsNullOrEmpty(_customRemoteBranchName)) + _customRemoteBranchName = _selectedRemoteBranch.Name; + + // Update tracking visibility for custom branch + if (_selectedLocalBranch != null && _selectedRemote != null && !string.IsNullOrEmpty(_customRemoteBranchName)) + { + var expectedUpstream = $"refs/remotes/{_selectedRemote.Name}/{_customRemoteBranchName}"; + IsSetTrackOptionVisible = _selectedLocalBranch.Upstream != expectedUpstream; + } + } + else + { + // When switching back to dropdown, update tracking visibility based on selected branch + if (_selectedRemoteBranch != null) + { + IsSetTrackOptionVisible = + _selectedRemoteBranch != null && + _selectedLocalBranch.Upstream != _selectedRemoteBranch.FullName; + } + } + } } } @@ -155,6 +214,9 @@ public Push(Repository repo, Models.Branch localBranch) public override bool CanStartDirectly() { + if (UseCustomBranchName) + return !string.IsNullOrEmpty(_customRemoteBranchName); + return !string.IsNullOrEmpty(_selectedRemoteBranch?.Head); } @@ -162,7 +224,10 @@ public override async Task Sure() { using var lockWatcher = _repo.LockWatcher(); - var remoteBranchName = _selectedRemoteBranch.Name; + var remoteBranchName = + UseCustomBranchName ? + _customRemoteBranchName : + _selectedRemoteBranch.Name; ProgressDescription = $"Push {_selectedLocalBranch.Name} -> {_selectedRemote.Name}/{remoteBranchName} ..."; var log = _repo.CreateLog("Push"); @@ -218,11 +283,7 @@ private void AutoSelectBranchByRemote() } // Add a fake new branch. - var fake = new Models.Branch() - { - Name = _selectedLocalBranch.Name, - Remote = _selectedRemote.Name, - }; + var fake = new Models.Branch { Name = _selectedLocalBranch.Name, Remote = _selectedRemote.Name }; branches.Add(fake); RemoteBranches = branches; SelectedRemoteBranch = fake; @@ -233,6 +294,8 @@ private void AutoSelectBranchByRemote() private Models.Remote _selectedRemote = null; private List _remoteBranches = []; private Models.Branch _selectedRemoteBranch = null; + private string _customRemoteBranchName = string.Empty; + private bool _useCustomBranchName = false; private bool _isSetTrackOptionVisible = false; } } diff --git a/src/Views/Push.axaml b/src/Views/Push.axaml index ae015c888..9eeb73ea9 100644 --- a/src/Views/Push.axaml +++ b/src/Views/Push.axaml @@ -12,7 +12,7 @@ Classes="bold" Text="{DynamicResource Text.Push.Title}"/> - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - -