From c10778c413ce50d1e704f6cbdd2075d602b419dd Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 24 May 2024 10:47:37 +0800 Subject: [PATCH] enhance: add an option to push tag to all remotes after created (#141) --- src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/ViewModels/CreateTag.cs | 22 +++++++++++++++++++--- src/ViewModels/PushTag.cs | 4 +++- src/Views/CreateTag.axaml | 8 ++++++-- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index c7993ffe..dff74a61 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -119,6 +119,7 @@ Optional. Tag Name : Recommended format :v1.0.0-alpha + Push to all remotes after created Kind : annotated lightweight diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 976bae32..17f8c128 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -119,6 +119,7 @@ 选填。 标签名 : 推荐格式 :v1.0.0-alpha + 推送到所有远程仓库 类型 : 附注标签 轻量标签 diff --git a/src/ViewModels/CreateTag.cs b/src/ViewModels/CreateTag.cs index 1c114763..7f1ac161 100644 --- a/src/ViewModels/CreateTag.cs +++ b/src/ViewModels/CreateTag.cs @@ -38,6 +38,12 @@ namespace SourceGit.ViewModels set; } = false; + public bool PushToAllRemotes + { + get; + set; + } = true; + public CreateTag(Repository repo, Models.Branch branch) { _repo = repo; @@ -75,13 +81,23 @@ namespace SourceGit.ViewModels return Task.Run(() => { + var succ = false; if (_annotated) - Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn, Message, SignTag); + succ = Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn, Message, SignTag); else - Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn); + succ = Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn); + + if (succ && PushToAllRemotes) + { + foreach (var remote in _repo.Remotes) + { + SetProgressDescription($"Pushing tag to remote {remote.Name} ..."); + new Commands.Push(_repo.FullPath, remote.Name, _tagName, false).Exec(); + } + } CallUIThread(() => _repo.SetWatcherEnabled(true)); - return true; + return succ; }); } diff --git a/src/ViewModels/PushTag.cs b/src/ViewModels/PushTag.cs index f9692d98..54673fbe 100644 --- a/src/ViewModels/PushTag.cs +++ b/src/ViewModels/PushTag.cs @@ -39,7 +39,7 @@ namespace SourceGit.ViewModels public override Task Sure() { _repo.SetWatcherEnabled(false); - ProgressDescription = $"Pushing tag '{Target.Name}' to remote '{SelectedRemote.Name}' ..."; + ProgressDescription = $"Pushing tag ..."; return Task.Run(() => { @@ -48,6 +48,7 @@ namespace SourceGit.ViewModels { foreach (var remote in _repo.Remotes) { + SetProgressDescription($"Pushing tag to remote {remote.Name} ..."); succ = new Commands.Push(_repo.FullPath, remote.Name, Target.Name, false).Exec(); if (!succ) break; @@ -55,6 +56,7 @@ namespace SourceGit.ViewModels } else { + SetProgressDescription($"Pushing tag to remote {SelectedRemote.Name} ..."); succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec(); } diff --git a/src/Views/CreateTag.axaml b/src/Views/CreateTag.axaml index 9ec7a046..a896a344 100644 --- a/src/Views/CreateTag.axaml +++ b/src/Views/CreateTag.axaml @@ -13,7 +13,7 @@ - + + +