From 6dad466eefd9255f9b814da31e4eeddd55e0456c Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 1 Jul 2024 16:19:08 +0800 Subject: [PATCH 1/2] feature: supports `--no-tags` on fetch and pull operation (#226) --- src/Commands/Fetch.cs | 12 +++++++++--- src/Commands/Pull.cs | 5 ++++- src/Resources/Locales/en_US.axaml | 2 ++ src/Resources/Locales/zh_CN.axaml | 2 ++ src/Resources/Locales/zh_TW.axaml | 2 ++ src/ViewModels/AddRemote.cs | 2 +- src/ViewModels/Fetch.cs | 13 +++++++++---- src/ViewModels/Pull.cs | 8 +++++++- src/Views/Fetch.axaml | 6 +++++- src/Views/Pull.axaml | 6 +++++- 10 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/Commands/Fetch.cs b/src/Commands/Fetch.cs index d65fee4e..ca1d83d6 100644 --- a/src/Commands/Fetch.cs +++ b/src/Commands/Fetch.cs @@ -7,7 +7,7 @@ namespace SourceGit.Commands { public class Fetch : Command { - public Fetch(string repo, string remote, bool prune, Action outputHandler) + public Fetch(string repo, string remote, bool prune, bool noTags, Action outputHandler) { _outputHandler = outputHandler; WorkingDirectory = repo; @@ -24,9 +24,15 @@ namespace SourceGit.Commands Args = "-c credential.helper=manager "; } - Args += "fetch --force --progress --verbose "; + Args += "fetch --progress --verbose "; if (prune) Args += "--prune "; + + if (noTags) + Args += "--no-tags "; + else + Args += "--force "; + Args += remote; AutoFetch.MarkFetched(repo); @@ -132,7 +138,7 @@ namespace SourceGit.Commands { var job = new Job { - Cmd = new Fetch(repo, "--all", true, null) { RaiseError = false }, + Cmd = new Fetch(repo, "--all", true, false, null) { RaiseError = false }, NextRunTimepoint = DateTime.Now.AddMinutes(Convert.ToDouble(Interval)), }; diff --git a/src/Commands/Pull.cs b/src/Commands/Pull.cs index d4f15dda..43418825 100644 --- a/src/Commands/Pull.cs +++ b/src/Commands/Pull.cs @@ -4,7 +4,7 @@ namespace SourceGit.Commands { public class Pull : Command { - public Pull(string repo, string remote, string branch, bool useRebase, Action outputHandler) + public Pull(string repo, string remote, string branch, bool useRebase, bool noTags, Action outputHandler) { _outputHandler = outputHandler; WorkingDirectory = repo; @@ -24,6 +24,9 @@ namespace SourceGit.Commands Args += "pull --verbose --progress --tags "; if (useRebase) Args += "--rebase "; + if (noTags) + Args += "--no-tags "; + Args += $"{remote} {branch}"; } diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 0586ee99..d3d41a8e 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -200,6 +200,7 @@ Fast-Forward (without checkout) Fetch Fetch all remotes + Fetch without tags Prune remote dead branches Remote: Fetch Remote Changes @@ -386,6 +387,7 @@ Discard Do Nothing Stash & Reapply + Fetch without tags Remote: Pull (Fetch & Merge) Use rebase instead of merge diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 3b6bfb9d..80d4c3b9 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -203,6 +203,7 @@ 快进(fast-forward,无需checkout) 拉取(fetch) 拉取所有的远程仓库 + 不拉取远程标签 自动清理远程已删除分支 远程仓库 : 拉取远程仓库内容 @@ -389,6 +390,7 @@ 丢弃更改 不做处理 贮藏并自动恢复 + 不拉取远程标签 远程 : 拉回(拉取并合并) 使用变基方式合并分支 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 5563a21a..b37b681f 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -203,6 +203,7 @@ 快進(fast-forward,無需checkout) 拉取(fetch) 拉取所有的遠端倉庫 + 不拉取遠端標籤 自動清理遠端已刪除分支 遠端倉庫 : 拉取遠端倉庫內容 @@ -389,6 +390,7 @@ 丟棄更改 不做處理 儲藏並自動恢復 + 不拉取遠端標籤 遠端 : 拉回(拉取併合並) 使用變基方式合併分支 diff --git a/src/ViewModels/AddRemote.cs b/src/ViewModels/AddRemote.cs index 296ddfdb..104a4ed6 100644 --- a/src/ViewModels/AddRemote.cs +++ b/src/ViewModels/AddRemote.cs @@ -100,7 +100,7 @@ namespace SourceGit.ViewModels { SetProgressDescription("Fetching from added remote ..."); new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null); - new Commands.Fetch(_repo.FullPath, _name, true, SetProgressDescription).Exec(); + new Commands.Fetch(_repo.FullPath, _name, true, false, SetProgressDescription).Exec(); } CallUIThread(() => { diff --git a/src/ViewModels/Fetch.cs b/src/ViewModels/Fetch.cs index 43ad49dc..3b33bbf2 100644 --- a/src/ViewModels/Fetch.cs +++ b/src/ViewModels/Fetch.cs @@ -26,14 +26,19 @@ namespace SourceGit.ViewModels { get; set; - } + } = true; + + public bool NoTags + { + get; + set; + } = false; public Fetch(Repository repo, Models.Remote preferedRemote = null) { _repo = repo; _fetchAllRemotes = preferedRemote == null; SelectedRemote = preferedRemote != null ? preferedRemote : _repo.Remotes[0]; - Prune = true; View = new Views.Fetch() { DataContext = this }; } @@ -47,13 +52,13 @@ namespace SourceGit.ViewModels foreach (var remote in _repo.Remotes) { SetProgressDescription($"Fetching remote: {remote.Name}"); - new Commands.Fetch(_repo.FullPath, remote.Name, Prune, SetProgressDescription).Exec(); + new Commands.Fetch(_repo.FullPath, remote.Name, Prune, NoTags, SetProgressDescription).Exec(); } } else { SetProgressDescription($"Fetching remote: {SelectedRemote.Name}"); - new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, Prune, SetProgressDescription).Exec(); + new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, Prune, NoTags, SetProgressDescription).Exec(); } CallUIThread(() => _repo.SetWatcherEnabled(true)); diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index 5a62f5b3..c210017f 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -59,6 +59,12 @@ namespace SourceGit.ViewModels set => _repo.Settings.PreferRebaseInsteadOfMerge = value; } + public bool NoTags + { + get; + set; + } = false; + public Pull(Repository repo, Models.Branch specifiedRemoteBranch) { _repo = repo; @@ -145,7 +151,7 @@ namespace SourceGit.ViewModels } SetProgressDescription($"Pull {_selectedRemote.Name}/{_selectedBranch.Name}..."); - var rs = new Commands.Pull(_repo.FullPath, _selectedRemote.Name, _selectedBranch.Name, UseRebase, SetProgressDescription).Exec(); + var rs = new Commands.Pull(_repo.FullPath, _selectedRemote.Name, _selectedBranch.Name, UseRebase, NoTags, SetProgressDescription).Exec(); if (rs && needPopStash) { SetProgressDescription("Re-apply local changes..."); diff --git a/src/Views/Fetch.axaml b/src/Views/Fetch.axaml index aaf9bec6..fbcf094b 100644 --- a/src/Views/Fetch.axaml +++ b/src/Views/Fetch.axaml @@ -12,7 +12,7 @@ - + + + diff --git a/src/Views/Pull.axaml b/src/Views/Pull.axaml index d2d1bebb..23d86e1e 100644 --- a/src/Views/Pull.axaml +++ b/src/Views/Pull.axaml @@ -13,7 +13,7 @@ - + + + From fca20965f8db0388b4711223dcb8f23fff748a95 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 1 Jul 2024 16:27:22 +0800 Subject: [PATCH 2/2] feature: add two color keys `Color.DecoratorBranch` and `Color.DecoratorTag` (#225) --- README.md | 4 ++++ src/Converters/DecoratorTypeConverters.cs | 4 ++-- src/Models/Decorator.cs | 12 +----------- src/Resources/Themes.axaml | 12 +++++++++--- src/Views/CommitBaseInfo.axaml | 2 +- src/Views/Histories.axaml | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 1f73b3c9..a2b36b58 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,10 @@ This app supports open repository in external tools listed in the table below. | Color.BadgeFG | Badge foreground color | | Color.Conflict | Conflict panel background color | | Color.ConflictForeground | Conflict panel foreground color | +| Color.DecoratorIconBG | Background color for commit ref icon | +| Color.DecoratorIcon | Foreground color for commit ref icon | +| Color.DecoratorBranch | Background color for commit branch ref name | +| Color.DecoratorTag | Background color for commit tag ref name | | Color.Border0 | Border color used in some controls, like Window, Tab, Toolbar, etc. | | Color.Border1 | Border color used in inputs, like TextBox, ComboBox, etc. | | Color.Border2 | Border color used in visual lines, like seperators, Rectange, etc. | diff --git a/src/Converters/DecoratorTypeConverters.cs b/src/Converters/DecoratorTypeConverters.cs index e19cb37c..f730b613 100644 --- a/src/Converters/DecoratorTypeConverters.cs +++ b/src/Converters/DecoratorTypeConverters.cs @@ -11,8 +11,8 @@ namespace SourceGit.Converters new FuncValueConverter(v => { if (v == Models.DecoratorType.Tag) - return Models.DecoratorResources.Backgrounds[0]; - return Models.DecoratorResources.Backgrounds[1]; + return Application.Current.FindResource("Brush.DecoratorTag") as IBrush; + return Application.Current.FindResource("Brush.DecoratorBranch") as IBrush; }); public static readonly FuncValueConverter ToIcon = diff --git a/src/Models/Decorator.cs b/src/Models/Decorator.cs index 60ffc1ee..235101cc 100644 --- a/src/Models/Decorator.cs +++ b/src/Models/Decorator.cs @@ -1,6 +1,4 @@ -using Avalonia.Media; - -namespace SourceGit.Models +namespace SourceGit.Models { public enum DecoratorType { @@ -17,12 +15,4 @@ namespace SourceGit.Models public DecoratorType Type { get; set; } = DecoratorType.None; public string Name { get; set; } = ""; } - - public static class DecoratorResources - { - public static readonly IBrush[] Backgrounds = [ - new SolidColorBrush(0xFF02C302), - new SolidColorBrush(0xFFFFB835), - ]; - } } diff --git a/src/Resources/Themes.axaml b/src/Resources/Themes.axaml index 56189cab..1f3a0d10 100644 --- a/src/Resources/Themes.axaml +++ b/src/Resources/Themes.axaml @@ -13,8 +13,10 @@ #FFFAFAFA #FFB0CEE8 #FF1F1F1F - #FF6F6F6F + #FF6F6F6F #FFF8F8F8 + #FFFFB835 + #FF02C302 #FF836C2E #FFFFFFFF #FFCFCFCF @@ -43,8 +45,10 @@ #FF1B1B1B #FF8F8F8F #FFDDDDDD - #FF505050 + #FF505050 #FFF8F8F8 + #FFFFB835 + #FF02C302 #FFFAFAD2 #FF252525 #FF181818 @@ -73,8 +77,10 @@ - + + + diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml index 42fa2b48..6e0429aa 100644 --- a/src/Views/CommitBaseInfo.axaml +++ b/src/Views/CommitBaseInfo.axaml @@ -90,7 +90,7 @@ - + diff --git a/src/Views/Histories.axaml b/src/Views/Histories.axaml index 565daa8e..d1aae81d 100644 --- a/src/Views/Histories.axaml +++ b/src/Views/Histories.axaml @@ -46,7 +46,7 @@ - +