diff --git a/src/Commands/Tag.cs b/src/Commands/Tag.cs index f96d3bc7..5fe57f94 100644 --- a/src/Commands/Tag.cs +++ b/src/Commands/Tag.cs @@ -5,12 +5,22 @@ namespace SourceGit.Commands { public static class Tag { - public static bool Add(string repo, string name, string basedOn, string message) + public static bool Add(string repo, string name, string basedOn) { var cmd = new Command(); cmd.WorkingDirectory = repo; cmd.Context = repo; - cmd.Args = $"tag -a {name} {basedOn} "; + cmd.Args = $"tag {name} {basedOn}"; + return cmd.Exec(); + } + + public static bool Add(string repo, string name, string basedOn, string message, bool sign) + { + var param = sign ? "-s -a" : "-a"; + var cmd = new Command(); + cmd.WorkingDirectory = repo; + cmd.Context = repo; + cmd.Args = $"tag {param} {name} {basedOn} "; if (!string.IsNullOrEmpty(message)) { diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index bf7d660e..c7993ffe 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -114,10 +114,14 @@ Create Local Branch Create Tag New Tag At : + Enable GPG signing Tag Message : Optional. Tag Name : Recommended format :v1.0.0-alpha + Kind : + annotated + lightweight Cut Delete Branch Branch : @@ -312,6 +316,7 @@ Remote Branch : Push all tags Push Tag To Remote + Push to all remotes Remote : Tag : Quit diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 9f464b79..976bae32 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -114,10 +114,14 @@ 创建本地分支 新建标签 标签位于 : + 使用GPG签名 标签描述 : 选填。 标签名 : 推荐格式 :v1.0.0-alpha + 类型 : + 附注标签 + 轻量标签 剪切 删除分支确认 分支名 : @@ -312,6 +316,7 @@ 远程分支 : 同时推送标签 推送标签到远程仓库 + 推送到所有远程仓库 远程仓库 : 标签 : 退出 diff --git a/src/ViewModels/CreateTag.cs b/src/ViewModels/CreateTag.cs index 34232bb2..1c114763 100644 --- a/src/ViewModels/CreateTag.cs +++ b/src/ViewModels/CreateTag.cs @@ -1,12 +1,16 @@ -using System; -using System.ComponentModel.DataAnnotations; -using System.Text.RegularExpressions; +using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; namespace SourceGit.ViewModels { public class CreateTag : Popup { + public object BasedOn + { + get; + private set; + } + [Required(ErrorMessage = "Tag name is required!")] [RegularExpression(@"^[\w\-\.]+$", ErrorMessage = "Bad tag name format!")] [CustomValidation(typeof(CreateTag), nameof(ValidateTagName))] @@ -22,11 +26,17 @@ namespace SourceGit.ViewModels set; } - public object BasedOn + public bool Annotated + { + get => _annotated; + set => SetProperty(ref _annotated, value); + } + + public bool SignTag { get; - private set; - } + set; + } = false; public CreateTag(Repository repo, Models.Branch branch) { @@ -65,7 +75,11 @@ namespace SourceGit.ViewModels return Task.Run(() => { - Commands.Tag.Add(_repo.FullPath, TagName, _basedOn, Message); + if (_annotated) + Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn, Message, SignTag); + else + Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn); + CallUIThread(() => _repo.SetWatcherEnabled(true)); return true; }); @@ -73,6 +87,7 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private string _tagName = string.Empty; + private bool _annotated = true; private readonly string _basedOn = string.Empty; } } diff --git a/src/ViewModels/PushTag.cs b/src/ViewModels/PushTag.cs index da8980a9..f9692d98 100644 --- a/src/ViewModels/PushTag.cs +++ b/src/ViewModels/PushTag.cs @@ -22,6 +22,12 @@ namespace SourceGit.ViewModels set; } + public bool PushAllRemotes + { + get => _pushAllRemotes; + set => SetProperty(ref _pushAllRemotes, value); + } + public PushTag(Repository repo, Models.Tag target) { _repo = repo; @@ -37,12 +43,27 @@ namespace SourceGit.ViewModels return Task.Run(() => { - var succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec(); + bool succ = true; + if (_pushAllRemotes) + { + foreach (var remote in _repo.Remotes) + { + succ = new Commands.Push(_repo.FullPath, remote.Name, Target.Name, false).Exec(); + if (!succ) + break; + } + } + else + { + succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec(); + } + CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; }); } private readonly Repository _repo = null; + private bool _pushAllRemotes = false; } } diff --git a/src/Views/ContextMenuExtension.cs b/src/Views/ContextMenuExtension.cs index 8e8479ec..7e7fe450 100644 --- a/src/Views/ContextMenuExtension.cs +++ b/src/Views/ContextMenuExtension.cs @@ -1,5 +1,4 @@ -using System; -using System.ComponentModel; +using System.ComponentModel; using Avalonia.Controls; diff --git a/src/Views/CreateTag.axaml b/src/Views/CreateTag.axaml index ac0b20c5..9ec7a046 100644 --- a/src/Views/CreateTag.axaml +++ b/src/Views/CreateTag.axaml @@ -13,7 +13,7 @@ - + + + + + + + - + + Text="{Binding Message, Mode=TwoWay}" + IsVisible="{Binding Annotated}"/> + + diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml index 6b696d5a..60ecf610 100644 --- a/src/Views/Preference.axaml +++ b/src/Views/Preference.axaml @@ -396,17 +396,10 @@ - - - - @@ -417,15 +410,19 @@ - - + + diff --git a/src/Views/Preference.axaml.cs b/src/Views/Preference.axaml.cs index 1dd77b50..1b5a432c 100644 --- a/src/Views/Preference.axaml.cs +++ b/src/Views/Preference.axaml.cs @@ -207,10 +207,17 @@ namespace SourceGit.Views private async void SelectGPGExecutable(object sender, RoutedEventArgs e) { - var pattern = OperatingSystem.IsWindows() ? "gpg.exe" : "gpg"; + var patterns = new List(); + if (OperatingSystem.IsWindows()) + patterns.Add("gpg.exe"); + else if (OperatingSystem.IsLinux()) + patterns.AddRange(new string[] { "gpg", "gpg2" }); + else + patterns.Add("gpg"); + var options = new FilePickerOpenOptions() { - FileTypeFilter = [new FilePickerFileType("GPG Executable") { Patterns = [pattern] }], + FileTypeFilter = [new FilePickerFileType("GPG Executable") { Patterns = patterns }], AllowMultiple = false, }; diff --git a/src/Views/PushTag.axaml b/src/Views/PushTag.axaml index f62d538a..1b24dc1b 100644 --- a/src/Views/PushTag.axaml +++ b/src/Views/PushTag.axaml @@ -12,7 +12,7 @@ - + + SelectedItem="{Binding SelectedRemote, Mode=TwoWay}" + IsEnabled="{Binding !PushAllRemotes}"> @@ -41,6 +42,10 @@ + + diff --git a/src/Views/RepositoryConfigure.axaml b/src/Views/RepositoryConfigure.axaml index 8e440089..3bcc7fff 100644 --- a/src/Views/RepositoryConfigure.axaml +++ b/src/Views/RepositoryConfigure.axaml @@ -47,23 +47,18 @@ Text="{Binding HttpProxy, Mode=TwoWay}"/> - - - - + Text="{Binding GPGUserSigningKey, Mode=TwoWay}"/> + +