From 3951549e5cb67141716035d1a31fae437d4bea35 Mon Sep 17 00:00:00 2001 From: aikawayataro Date: Tue, 8 Oct 2024 08:07:50 +0000 Subject: [PATCH 01/27] enhance: append to PATH on MacOS instead of overriding it (#546) --- src/Commands/Command.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index 55fc6d17..72c10b0c 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -199,7 +199,17 @@ namespace SourceGit.Commands // Fix sometimes `LSEnvironment` not working on macOS if (OperatingSystem.IsMacOS()) - start.Environment.Add("PATH", "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"); + { + if (start.Environment.TryGetValue("PATH", out var path)) + { + path = "/opt/homebrew/bin:/opt/homebrew/sbin:" + path; + } + else + { + path = "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"; + } + start.Environment.Add("PATH", path); + } // Force using this app as git editor. switch (Editor) From 8ddf6e87e913ac890740b392491cd759be7e95ed Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 8 Oct 2024 16:19:03 +0800 Subject: [PATCH 02/27] enhance: set `GIT_SSH_COMMAND` only if it has not been provided (#544) --- src/Commands/Command.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index 72c10b0c..7435dbfa 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -188,10 +188,8 @@ namespace SourceGit.Commands start.Environment.Add("SOURCEGIT_LAUNCH_AS_ASKPASS", "TRUE"); // If an SSH private key was provided, sets the environment. - if (!string.IsNullOrEmpty(SSHKey)) - start.Environment.Add("GIT_SSH_COMMAND", $"ssh -o StrictHostKeyChecking=accept-new -i '{SSHKey}'"); - else - start.Environment.Add("GIT_SSH_COMMAND", $"ssh -o StrictHostKeyChecking=accept-new"); + if (!start.Environment.ContainsKey("GIT_SSH_COMMAND") && !string.IsNullOrEmpty(SSHKey)) + start.Environment.Add("GIT_SSH_COMMAND", $"ssh -i '{SSHKey}'"); // Force using en_US.UTF-8 locale to avoid GCM crash if (OperatingSystem.IsLinux()) @@ -201,14 +199,9 @@ namespace SourceGit.Commands if (OperatingSystem.IsMacOS()) { if (start.Environment.TryGetValue("PATH", out var path)) - { - path = "/opt/homebrew/bin:/opt/homebrew/sbin:" + path; - } + start.Environment.Add("PATH", $"/opt/homebrew/bin:/opt/homebrew/sbin:{path}"); else - { - path = "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"; - } - start.Environment.Add("PATH", path); + start.Environment.Add("PATH", "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"); } // Force using this app as git editor. From eab36f08b32df62b654a975ff0bcd0041a136053 Mon Sep 17 00:00:00 2001 From: Nils van Rijsinge Date: Wed, 9 Oct 2024 03:15:57 +0200 Subject: [PATCH 03/27] localization: add DE keys for new features (#547) InCurrentBranch added in 130c98a Repo.CommitWithAutoStage added in 9a8f4e2 Workingcopy.CommitWithAutostage added in 9a8f4e2 and updated in 19e930e, 99c2ffe CommitTip updated in 99c2ffe IgnoreWhitespace added in d2a005c DefaultRemote added in d746e35 IncludeIgnored added in 4e57cd5 --- src/Resources/Locales/de_DE.axaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 95c3f07f..94cd8330 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -206,6 +206,7 @@ ALT Kopieren Dateimodus geändert + Ignoriere Leerzeichenänderungen LFS OBJEKT ÄNDERUNG Nächste Änderung KEINE ÄNDERUNG ODER NUR ZEILEN-ENDE ÄNDERUNGEN @@ -225,6 +226,7 @@ Änderungen verwerfen Alle Änderungen in der Arbeitskopie. Änderungen: + Ignorierte Dateien inkludieren Insgesamt {0} Änderungen werden verworfen Du kannst das nicht rückgängig machen!!! Lesezeichen: @@ -330,6 +332,7 @@ REPOSITORY Gestagte Änderungen committen Gestagte Änderungen committen und pushen + Alle Änderungen stagen und committen Ausgewählte Änderungen verwerfen Dashboard Modus (Standard) Erzwinge Neuladen des Repositorys @@ -493,6 +496,7 @@ Branch: ABBRECHEN Änderungen automatisch von Remote fetchen... + Standard Remote Aufräumen (GC & Prune) Führt `git gc` auf diesem Repository aus. Alles löschen @@ -516,6 +520,7 @@ Commit-Nachricht SHA Autor & Committer + Aktueller Branch| Zeige Tags als Baum Statistiken SUBMODULE @@ -623,6 +628,8 @@ COMMIT COMMIT & PUSH Template/Historie + Klick-Ereignis auslösen + Alle Änderungen stagen und committen KONFLIKTE ERKANNT DATEI KONFLIKTE GELÖST NICHT-VERFOLGTE DATEIEN INKLUDIEREN From fb62732a9271d6cd3d653f5133819e140c0b08f9 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 9 Oct 2024 09:18:30 +0800 Subject: [PATCH 04/27] code_review: PR #547 * syntax error at line 523 * keep keys in order --- src/Resources/Locales/de_DE.axaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 94cd8330..105ad78f 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -141,6 +141,7 @@ GIT Remotes automatisch fetchen Minute(n) + Standard Remote TICKETSYSTEM Beispiel für Github-Regel hinzufügen Beispiel für Jira-Regel hinzufügen @@ -496,7 +497,6 @@ Branch: ABBRECHEN Änderungen automatisch von Remote fetchen... - Standard Remote Aufräumen (GC & Prune) Führt `git gc` auf diesem Repository aus. Alles löschen @@ -520,7 +520,7 @@ Commit-Nachricht SHA Autor & Committer - Aktueller Branch| + Aktueller Branch Zeige Tags als Baum Statistiken SUBMODULE From 857ba85d9f883a500ce5424fa2a4b697a771bd3c Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 9 Oct 2024 09:41:37 +0800 Subject: [PATCH 05/27] ux: do not use small font size for branches/tags/submodules search box --- src/Resources/Locales/de_DE.axaml | 2 +- src/Resources/Locales/en_US.axaml | 2 +- src/Resources/Locales/fr_FR.axaml | 3 +-- src/Resources/Locales/pt_BR.axaml | 2 +- src/Resources/Locales/zh_CN.axaml | 2 +- src/Resources/Locales/zh_TW.axaml | 2 +- src/Views/Repository.axaml | 8 +------- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 105ad78f..3440d12c 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -503,7 +503,7 @@ Repository Einstellungen WEITER Öffne im Datei-Browser - Suche Branches & Tags & Submodule + Suche Branches/Tags/Submodule GEFILTERT: LOKALE BRANCHES Zum HEAD wechseln diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index b4f52b55..172d8ae2 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -500,7 +500,7 @@ Configure this repository CONTINUE Open In File Browser - Search Branches & Tags & Submodules + Search Branches/Tags/Submodules FILTERED BY: LOCAL BRANCHES Navigate To HEAD diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index c90a19cb..c047e7d7 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -2,7 +2,6 @@ - À propos • Compilé avec © 2024 sourcegit-scm @@ -479,7 +478,7 @@ Configure this repository CONTINUE Ouvrir dans l'explorateur Windows - Search Branches & Tags & Submodules + Search Branches/Tags/Submodules FILTERED BY: LOCAL BRANCHES Navigate To HEAD diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index b0505014..57ce05ef 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -471,7 +471,7 @@ Configurar este repositório CONTINUAR Abrir no Navegador de Arquivos - Pesquisar Branches & Tags & Submódulos + Pesquisar Branches/Tags/Submódulos FILTRADO POR: BRANCHES LOCAIS Navegar para HEAD diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 57712fa5..62178b51 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -498,7 +498,7 @@ 配置本仓库 下一步 在文件浏览器中打开 - 快速查找分支、标签、子模块 + 快速查找分支/标签/子模块 过滤规则 : 本地分支 定位HEAD diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 7abfb36a..1d16bde9 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -503,7 +503,7 @@ 設定本存放庫 下一步 在檔案瀏覽器中開啟 - 快速搜尋分支、標籤、子模組 + 快速搜尋分支/標籤/子模組 篩選規則: 本機分支 回到 HEAD diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 2ed9d8f8..522f9ee3 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -128,13 +128,7 @@ BorderBrush="{DynamicResource Brush.Border2}" Watermark="{DynamicResource Text.Repository.Filter}" Text="{Binding Filter, Mode=TwoWay}" - VerticalContentAlignment="Center"> - - - - + VerticalContentAlignment="Center"> Date: Wed, 9 Oct 2024 11:55:24 +0800 Subject: [PATCH 06/27] fix: turn off `GPG Signing` when create a new tag does not work if `tag.gpgsign` is enabled --- src/Commands/Tag.cs | 2 +- src/ViewModels/CreateTag.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Commands/Tag.cs b/src/Commands/Tag.cs index 5fe57f94..fa11e366 100644 --- a/src/Commands/Tag.cs +++ b/src/Commands/Tag.cs @@ -16,7 +16,7 @@ namespace SourceGit.Commands public static bool Add(string repo, string name, string basedOn, string message, bool sign) { - var param = sign ? "-s -a" : "-a"; + var param = sign ? "--sign -a" : "--no-sign -a"; var cmd = new Command(); cmd.WorkingDirectory = repo; cmd.Context = repo; diff --git a/src/ViewModels/CreateTag.cs b/src/ViewModels/CreateTag.cs index 7318e00e..af9dcf99 100644 --- a/src/ViewModels/CreateTag.cs +++ b/src/ViewModels/CreateTag.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.DataAnnotations; +using System; +using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; namespace SourceGit.ViewModels @@ -50,6 +51,7 @@ namespace SourceGit.ViewModels _basedOn = branch.Head; BasedOn = branch; + SignTag = new Commands.Config(repo.FullPath).Get("tag.gpgsign").Equals("true", StringComparison.OrdinalIgnoreCase); View = new Views.CreateTag() { DataContext = this }; } @@ -59,6 +61,7 @@ namespace SourceGit.ViewModels _basedOn = commit.SHA; BasedOn = commit; + SignTag = new Commands.Config(repo.FullPath).Get("tag.gpgsign").Equals("true", StringComparison.OrdinalIgnoreCase); View = new Views.CreateTag() { DataContext = this }; } From 4d14302929726ac0d31273fd6c2c075b46ce6158 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 9 Oct 2024 14:20:43 +0800 Subject: [PATCH 07/27] refactor: remove scope parameter while getting git configuration (#544) --- src/Commands/Config.cs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Commands/Config.cs b/src/Commands/Config.cs index 53416c86..2fb83325 100644 --- a/src/Commands/Config.cs +++ b/src/Commands/Config.cs @@ -7,17 +7,23 @@ namespace SourceGit.Commands { public Config(string repository) { - WorkingDirectory = repository; - Context = repository; + if (string.IsNullOrEmpty(repository)) + { + WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + } + else + { + WorkingDirectory = repository; + Context = repository; + _isLocal = true; + } + RaiseError = false; } public Dictionary ListAll() { - if (string.IsNullOrEmpty(WorkingDirectory)) - Args = "config --global -l"; - else - Args = "config -l"; + Args = "config -l"; var output = ReadToEnd(); var rs = new Dictionary(); @@ -47,22 +53,16 @@ namespace SourceGit.Commands public bool Set(string key, string value, bool allowEmpty = false) { + var scope = _isLocal ? "--local" : "--global"; + if (!allowEmpty && string.IsNullOrWhiteSpace(value)) - { - if (string.IsNullOrEmpty(WorkingDirectory)) - Args = $"config --global --unset {key}"; - else - Args = $"config --unset {key}"; - } + Args = $"config {scope} --unset {key}"; else - { - if (string.IsNullOrWhiteSpace(WorkingDirectory)) - Args = $"config --global {key} \"{value}\""; - else - Args = $"config {key} \"{value}\""; - } + Args = $"config {scope} {key} \"{value}\""; return Exec(); } + + private bool _isLocal = false; } } From bfb97dff720798722cfcb74a0cba3fb1a48c29d2 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 9 Oct 2024 15:30:25 +0800 Subject: [PATCH 08/27] ux: warning text style --- src/Views/CheckoutCommit.axaml | 3 ++- src/Views/Discard.axaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Views/CheckoutCommit.axaml b/src/Views/CheckoutCommit.axaml index 521d2b08..37021565 100644 --- a/src/Views/CheckoutCommit.axaml +++ b/src/Views/CheckoutCommit.axaml @@ -43,7 +43,8 @@ Fill="DarkOrange"/> + TextWrapping="Wrap" + Foreground="DarkOrange"/> diff --git a/src/Views/Discard.axaml b/src/Views/Discard.axaml index d37662b0..23162060 100644 --- a/src/Views/Discard.axaml +++ b/src/Views/Discard.axaml @@ -18,7 +18,7 @@ Fill="DarkOrange"/> + Foreground="DarkOrange"/> From c8a13bc4e9ff082af149fe1fd3bd33a348037d54 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 9 Oct 2024 15:58:44 +0800 Subject: [PATCH 09/27] enhance: returns the instance of `ViewModels.Preference` directly if it exists --- src/ViewModels/Preference.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs index 68966f5d..49d70365 100644 --- a/src/ViewModels/Preference.cs +++ b/src/ViewModels/Preference.cs @@ -15,16 +15,17 @@ namespace SourceGit.ViewModels { get { - if (_instance == null) - { - _isLoading = true; - _instance = Load(); - _isLoading = false; - } + if (_instance != null) + return _instance; + + _isLoading = true; + _instance = Load(); + _isLoading = false; _instance.PrepareGit(); _instance.PrepareShellOrTerminal(); _instance.PrepareWorkspaces(); + return _instance; } } From 14334b08d2728a99cab5477ee6e090a8d226059e Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 9 Oct 2024 17:29:53 +0800 Subject: [PATCH 10/27] enhance: do not save `gpg.openpgp.program` if `gpg.program` exists and the value has not been changed (#544) --- src/Views/Preference.axaml.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Views/Preference.axaml.cs b/src/Views/Preference.axaml.cs index af70ee8e..2f08e0db 100644 --- a/src/Views/Preference.axaml.cs +++ b/src/Views/Preference.axaml.cs @@ -137,7 +137,22 @@ namespace SourceGit.Views SetIfChanged(config, "gpg.format", GPGFormat.Value, "openpgp"); if (!GPGFormat.Value.Equals("ssh", StringComparison.Ordinal)) - SetIfChanged(config, $"gpg.{GPGFormat.Value}.program", GPGExecutableFile, ""); + { + var oldGPG = string.Empty; + if (GPGFormat.Value == "openpgp" && config.TryGetValue("gpg.program", out var openpgp)) + oldGPG = openpgp; + else if (config.TryGetValue($"gpg.{GPGFormat.Value}.program", out var gpgProgram)) + oldGPG = gpgProgram; + + bool changed = false; + if (!string.IsNullOrEmpty(oldGPG)) + changed = oldGPG != GPGExecutableFile; + else if (!string.IsNullOrEmpty(GPGExecutableFile)) + changed = true; + + if (changed) + new Commands.Config(null).Set($"gpg.{GPGFormat.Value}.program", GPGExecutableFile); + } base.OnClosing(e); } From ac74e4ba32a043c67daa1df2dded09621c10e27e Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 10 Oct 2024 09:17:31 +0800 Subject: [PATCH 11/27] enhance: change the default reset mode to `--mixed` which is the default action in git commandline (#551) --- src/ViewModels/Reset.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ViewModels/Reset.cs b/src/ViewModels/Reset.cs index ba3a3794..9500f40a 100644 --- a/src/ViewModels/Reset.cs +++ b/src/ViewModels/Reset.cs @@ -27,7 +27,7 @@ namespace SourceGit.ViewModels _repo = repo; Current = current; To = to; - SelectedMode = Models.ResetMode.Supported[0]; + SelectedMode = Models.ResetMode.Supported[1]; View = new Views.Reset() { DataContext = this }; } From 68519c76ca57b7d0411e3baf046ddbcf549d8ce1 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 10 Oct 2024 11:54:59 +0800 Subject: [PATCH 12/27] refactor: stash local changes (#550) * when try to stash all the local changes, add a option to only stash the staged changes * stash changes in selected files will prompt user - both staged and unstaged changes of selected file(s) will be stashed --- src/Resources/Locales/en_US.axaml | 2 ++ src/Resources/Locales/zh_CN.axaml | 2 ++ src/Resources/Locales/zh_TW.axaml | 2 ++ src/ViewModels/StashChanges.cs | 20 +++++++++++++------- src/ViewModels/WorkingCopy.cs | 15 +++++++-------- src/Views/StashChanges.axaml | 17 +++++++++++++++-- 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 172d8ae2..0cc0f0a1 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -562,6 +562,8 @@ Include untracked files Message: Optional. Name of this stash + Only staged changes + Both staged and unstaged changes of selected file(s) will be stashed!!! Stash Local Changes Apply Drop diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 62178b51..fe93e7d1 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -560,6 +560,8 @@ 包含未跟踪的文件 信息 : 选填,用于命名此贮藏 + 仅贮藏暂存区的变更 + 选中文件的所有变更均会被贮藏! 贮藏本地变更 应用(apply) 删除(drop) diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 1d16bde9..a75c1441 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -565,6 +565,8 @@ 包含未追蹤的檔案 擱置變更訊息: 選填,用於命名此擱置變更 + 僅擱置已暫存的變更 + 選中檔案的所有變更均會被擱置! 擱置本機變更 套用 (apply) 刪除 (drop) diff --git a/src/ViewModels/StashChanges.cs b/src/ViewModels/StashChanges.cs index abc45492..ed3d2bfd 100644 --- a/src/ViewModels/StashChanges.cs +++ b/src/ViewModels/StashChanges.cs @@ -11,7 +11,7 @@ namespace SourceGit.ViewModels set; } - public bool CanIgnoreUntracked + public bool HasSelectedFiles { get; } @@ -22,21 +22,28 @@ namespace SourceGit.ViewModels set; } - public StashChanges(Repository repo, List changes, bool onlyStaged, bool canIgnoreUntracked) + public bool OnlyStaged + { + get; + set; + } + + public StashChanges(Repository repo, List changes, bool hasSelectedFiles) { _repo = repo; _changes = changes; - _onlyStaged = onlyStaged; - CanIgnoreUntracked = canIgnoreUntracked; + HasSelectedFiles = hasSelectedFiles; IncludeUntracked = true; + OnlyStaged = false; + View = new Views.StashChanges() { DataContext = this }; } public override Task Sure() { var jobs = _changes; - if (CanIgnoreUntracked && !IncludeUntracked) + if (!HasSelectedFiles && !IncludeUntracked) { jobs = new List(); foreach (var job in _changes) @@ -56,7 +63,7 @@ namespace SourceGit.ViewModels return Task.Run(() => { - var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, _onlyStaged); + var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, !HasSelectedFiles && OnlyStaged); CallUIThread(() => { _repo.MarkWorkingCopyDirtyManually(); @@ -68,6 +75,5 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private readonly List _changes = null; - private readonly bool _onlyStaged = false; } } diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 4bfb10bc..e4acf8ca 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -318,9 +318,9 @@ namespace SourceGit.ViewModels return; if (autoStart) - PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, false, true)); + PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, false)); else - PopupHost.ShowPopup(new StashChanges(_repo, _cached, false, true)); + PopupHost.ShowPopup(new StashChanges(_repo, _cached, false)); } public void StageSelected(Models.Change next) @@ -523,9 +523,8 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - { - PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false)); - } + PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, true)); + e.Handled = true; }; @@ -843,7 +842,7 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, true)); e.Handled = true; }; @@ -928,7 +927,7 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true)); e.Handled = true; }; @@ -1097,7 +1096,7 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true)); e.Handled = true; }; diff --git a/src/Views/StashChanges.axaml b/src/Views/StashChanges.axaml index 95299ff1..5396da4d 100644 --- a/src/Views/StashChanges.axaml +++ b/src/Views/StashChanges.axaml @@ -11,7 +11,7 @@ - + + + + IsVisible="{Binding !HasSelectedFiles}"/> + + From 93706449be68704b3a88f8bf8f934aab7bbc0230 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 10 Oct 2024 15:42:26 +0800 Subject: [PATCH 13/27] enhance: only update grammar if it is necessary --- src/Models/TextMateHelper.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Models/TextMateHelper.cs b/src/Models/TextMateHelper.cs index 2e38e4dd..0eb5e489 100644 --- a/src/Models/TextMateHelper.cs +++ b/src/Models/TextMateHelper.cs @@ -81,6 +81,8 @@ namespace SourceGit.Models public class RegistryOptionsWrapper(ThemeName defaultTheme) : IRegistryOptions { + public string LastScope { get; set; } = string.Empty; + public IRawTheme GetTheme(string scopeName) => _backend.GetTheme(scopeName); public IRawTheme GetDefaultTheme() => _backend.GetDefaultTheme(); public IRawTheme LoadTheme(ThemeName name) => _backend.LoadTheme(name); @@ -111,10 +113,15 @@ namespace SourceGit.Models public static void SetGrammarByFileName(TextMate.Installation installation, string filePath) { - if (installation is { RegistryOptions: RegistryOptionsWrapper reg }) + if (installation is { RegistryOptions: RegistryOptionsWrapper reg } && !string.IsNullOrEmpty(filePath)) { - installation.SetGrammar(reg.GetScope(filePath)); - GC.Collect(); + var scope = reg.GetScope(filePath); + if (reg.LastScope != scope) + { + reg.LastScope = scope; + installation.SetGrammar(reg.GetScope(filePath)); + GC.Collect(); + } } } } From c2b17ef9d032a3c23610c5c531b86c5ae5184bd5 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 11 Oct 2024 10:03:42 +0800 Subject: [PATCH 14/27] fix: changing the repository URL only changes the fetch URL if push URL using a different URL (#553) --- src/Commands/Remote.cs | 12 ++++++++++-- src/ViewModels/EditRemote.cs | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Commands/Remote.cs b/src/Commands/Remote.cs index 46aa37e3..f2e8d09e 100644 --- a/src/Commands/Remote.cs +++ b/src/Commands/Remote.cs @@ -32,9 +32,17 @@ return Exec(); } - public bool SetURL(string name, string url) + public string GetURL(string name, bool isPush) { - Args = $"remote set-url {name} {url}"; + Args = "remote get-url" + (isPush ? " --push " : " ") + name; + + var rs = ReadToEnd(); + return rs.IsSuccess ? rs.StdOut.Trim() : string.Empty; + } + + public bool SetURL(string name, string url, bool isPush) + { + Args = "remote set-url" + (isPush ? " --push " : " ") + $"{name} {url}"; return Exec(); } } diff --git a/src/ViewModels/EditRemote.cs b/src/ViewModels/EditRemote.cs index 0a514324..912c7991 100644 --- a/src/ViewModels/EditRemote.cs +++ b/src/ViewModels/EditRemote.cs @@ -118,11 +118,15 @@ namespace SourceGit.ViewModels if (_remote.URL != _url) { - var succ = new Commands.Remote(_repo.FullPath).SetURL(_name, _url); + var succ = new Commands.Remote(_repo.FullPath).SetURL(_name, _url, false); if (succ) _remote.URL = _url; } + var pushURL = new Commands.Remote(_repo.FullPath).GetURL(_name, true); + if (pushURL != _url) + new Commands.Remote(_repo.FullPath).SetURL(_name, _url, true); + SetProgressDescription("Post processing ..."); new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null); From b5000f920f39791ef293972f2ebe217d2abd33a1 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 11 Oct 2024 11:04:27 +0800 Subject: [PATCH 15/27] enhance: highlight selected search commits --- src/ViewModels/Histories.cs | 6 +++++- src/Views/Repository.axaml | 6 ------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index b5a72763..10f4b60a 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -153,7 +153,11 @@ namespace SourceGit.ViewModels else if (commits.Count == 1) { var commit = commits[0] as Models.Commit; - _repo.SearchResultSelectedCommit = commit; + + if (_repo.SearchResultSelectedCommit == null || _repo.SearchResultSelectedCommit.SHA != commit.SHA) + { + _repo.SearchResultSelectedCommit = _repo.SearchedCommits.Find(x => x.SHA == commit.SHA); + } AutoSelectedCommit = commit; NavigationId = _navigationId + 1; diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index 522f9ee3..63c73938 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -460,12 +460,6 @@ - - From 6ca6399bd3d4f6d0501bbf8cf4211b5b1345423b Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 11 Oct 2024 11:29:33 +0800 Subject: [PATCH 16/27] enhance: re-run searching after search option changes --- src/ViewModels/Repository.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 8038f333..1a9b9955 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -213,7 +213,12 @@ namespace SourceGit.ViewModels public bool OnlySearchCommitsInCurrentBranch { get => _onlySearchCommitsInCurrentBranch; - set => SetProperty(ref _onlySearchCommitsInCurrentBranch, value); + set + { + if (SetProperty(ref _onlySearchCommitsInCurrentBranch, value) && + !string.IsNullOrEmpty(_searchCommitFilter)) + StartSearchCommits(); + } } public int SearchCommitFilterType @@ -222,7 +227,12 @@ namespace SourceGit.ViewModels set { if (SetProperty(ref _searchCommitFilterType, value)) + { UpdateCurrentRevisionFilesForSearchSuggestion(); + + if (!string.IsNullOrEmpty(_searchCommitFilter)) + StartSearchCommits(); + } } } From c67cdb931f4f649d775f2f3cd70523f5207c4d08 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 11 Oct 2024 17:37:34 +0800 Subject: [PATCH 17/27] enhance: stop switching workspace when one or more tasks are running in opened pages --- src/ViewModels/Launcher.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index 5abf50e8..dd618e41 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -465,6 +465,15 @@ namespace SourceGit.ViewModels private void SwitchWorkspace(Workspace to) { + foreach (var one in Pages) + { + if (one.IsInProgress()) + { + App.RaiseException(null, "You have unfinished task(s) in opened pages. Please wait!!!"); + return; + } + } + _ignoreIndexChange = true; var pref = Preference.Instance; From 1f7a54e61e0c6c55a625848fafd0c5af6df48f78 Mon Sep 17 00:00:00 2001 From: AquariusStar <48148723+AquariusStar@users.noreply.github.com> Date: Sat, 12 Oct 2024 04:21:04 +0300 Subject: [PATCH 18/27] Work on translation (#559) --- src/Resources/Locales/ru_RU.axaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index ceda8a9f..60abd646 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -560,6 +560,8 @@ В: Частный ключ SSH: Путь хранения частного ключа SSH + Только подготовленные изменения + Подготовленные так и подготовленные изменения выбранных файлов будут сохранены!!! ЗАПУСК Отложить Включить неотслеживаемые файлы From 21e15a1af475862d9219785b887cf95fc68cbe2b Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 12 Oct 2024 09:56:33 +0800 Subject: [PATCH 19/27] feature: add a toggle in perference to show author time instead of committer time in graph (#558) --- src/Resources/Locales/en_US.axaml | 2 ++ src/Resources/Locales/zh_CN.axaml | 2 ++ src/Resources/Locales/zh_TW.axaml | 2 ++ src/ViewModels/Preference.cs | 7 ++++++ src/Views/Histories.axaml | 13 ++++++++--- src/Views/Histories.axaml.cs | 37 ++++++++++++++++++++----------- src/Views/Preference.axaml | 7 +++++- 7 files changed, 53 insertions(+), 17 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 0cc0f0a1..bd2efd9c 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -313,6 +313,7 @@ Switch Horizontal/Vertical Layout Switch Curve/Polyline Graph Mode AUTHOR + AUTHOR TIME GRAPH & SUBJECT SHA COMMIT TIME @@ -414,6 +415,7 @@ Check for updates on startup Language History Commits + Show author time intead of commit time in graph Subject Guide Length GIT Enable Auto CRLF diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index fe93e7d1..78e455d3 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -316,6 +316,7 @@ 切换横向/纵向显示 切换曲线/折线显示 作者 + 修改时间 路线图与主题 提交指纹 提交时间 @@ -413,6 +414,7 @@ 启动时检测软件更新 显示语言 最大历史提交数 + 在提交路线图中显示修改时间而非提交时间 SUBJECT字数检测 GIT配置 自动换行转换 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index a75c1441..64ae8b06 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -316,6 +316,7 @@ 切換橫向/縱向顯示 切換曲線/折線顯示 作者 + 修改時間 路線圖與訊息標題 提交編號 提交時間 @@ -417,6 +418,7 @@ 啟動時檢查軟體更新 顯示語言 最大歷史提交數 + 在提交路線圖中顯示修改時間而非提交時間 提交標題字數偵測 Git 設定 自動換行轉換 diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs index 49d70365..7a635498 100644 --- a/src/ViewModels/Preference.cs +++ b/src/ViewModels/Preference.cs @@ -132,6 +132,12 @@ namespace SourceGit.ViewModels set => SetProperty(ref _check4UpdatesOnStartup, value); } + public bool ShowAuthorTimeInGraph + { + get => _showAuthorTimeInGraph; + set => SetProperty(ref _showAuthorTimeInGraph, value); + } + public string IgnoreUpdateTag { get => _ignoreUpdateTag; @@ -577,6 +583,7 @@ namespace SourceGit.ViewModels private int _maxHistoryCommits = 20000; private int _subjectGuideLength = 50; private bool _useFixedTabWidth = true; + private bool _showAuthorTimeInGraph = false; private bool _check4UpdatesOnStartup = true; private double _lastCheckUpdateTime = 0; diff --git a/src/Views/Histories.axaml b/src/Views/Histories.axaml index 3996554d..65ec029d 100644 --- a/src/Views/Histories.axaml +++ b/src/Views/Histories.axaml @@ -51,7 +51,14 @@ - + + @@ -180,13 +187,13 @@ Opacity="{Binding Opacity}"/> - + diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index 2c8014ca..66aac50b 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -303,13 +303,13 @@ namespace SourceGit.Views set => SetValue(ShowAsDateTimeProperty, value); } - public static readonly StyledProperty TimestampProperty = - AvaloniaProperty.Register(nameof(Timestamp)); + public static readonly StyledProperty UseAuthorTimeProperty = + AvaloniaProperty.Register(nameof(UseAuthorTime), true); - public ulong Timestamp + public bool UseAuthorTime { - get => GetValue(TimestampProperty); - set => SetValue(TimestampProperty, value); + get => GetValue(UseAuthorTimeProperty); + set => SetValue(UseAuthorTimeProperty, value); } protected override Type StyleKeyOverride => typeof(TextBlock); @@ -318,7 +318,7 @@ namespace SourceGit.Views { base.OnPropertyChanged(change); - if (change.Property == TimestampProperty) + if (change.Property == UseAuthorTimeProperty) { SetCurrentValue(TextProperty, GetDisplayText()); } @@ -347,6 +347,12 @@ namespace SourceGit.Views StopTimer(); } + protected override void OnDataContextChanged(EventArgs e) + { + base.OnDataContextChanged(e); + SetCurrentValue(TextProperty, GetDisplayText()); + } + private void StartTimer() { if (_refreshTimer != null) @@ -376,30 +382,35 @@ namespace SourceGit.Views private string GetDisplayText() { + var commit = DataContext as Models.Commit; + if (commit == null) + return string.Empty; + + var timestamp = UseAuthorTime ? commit.AuthorTime : commit.CommitterTime; if (ShowAsDateTime) - return DateTime.UnixEpoch.AddSeconds(Timestamp).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); + return DateTime.UnixEpoch.AddSeconds(timestamp).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); var today = DateTime.Today; - var committerTime = DateTime.UnixEpoch.AddSeconds(Timestamp).ToLocalTime(); + var localTime = DateTime.UnixEpoch.AddSeconds(timestamp).ToLocalTime(); - if (committerTime >= today) + if (localTime >= today) { var now = DateTime.Now; - var timespan = now - committerTime; + var timespan = now - localTime; if (timespan.TotalHours > 1) return App.Text("Period.HoursAgo", (int)timespan.TotalHours); return timespan.TotalMinutes < 1 ? App.Text("Period.JustNow") : App.Text("Period.MinutesAgo", (int)timespan.TotalMinutes); } - var diffYear = today.Year - committerTime.Year; + var diffYear = today.Year - localTime.Year; if (diffYear == 0) { - var diffMonth = today.Month - committerTime.Month; + var diffMonth = today.Month - localTime.Month; if (diffMonth > 0) return diffMonth == 1 ? App.Text("Period.LastMonth") : App.Text("Period.MonthsAgo", diffMonth); - var diffDay = today.Day - committerTime.Day; + var diffDay = today.Day - localTime.Day; return diffDay == 1 ? App.Text("Period.Yesterday") : App.Text("Period.DaysAgo", diffDay); } diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml index 88d335e3..1198008e 100644 --- a/src/Views/Preference.axaml +++ b/src/Views/Preference.axaml @@ -52,7 +52,7 @@ - + + + From adca61c5386e987a94801b0b6399d909fd507c03 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 12 Oct 2024 09:59:19 +0800 Subject: [PATCH 20/27] ux: re-order items in preference panel --- src/Views/Preference.axaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml index 1198008e..0b01202b 100644 --- a/src/Views/Preference.axaml +++ b/src/Views/Preference.axaml @@ -114,13 +114,13 @@ + Content="{DynamicResource Text.Preference.General.ShowAuthorTime}" + IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowAuthorTimeInGraph, Mode=TwoWay}"/> + Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}" + IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/> From b9a24ceb53027026c5622a1a565ef71f78a52cf7 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 12 Oct 2024 10:28:54 +0800 Subject: [PATCH 21/27] feature: add hotkeys to move interactive rebase item up and down (#557) --- src/Resources/Locales/de_DE.axaml | 2 - src/Resources/Locales/en_US.axaml | 2 - src/Resources/Locales/fr_FR.axaml | 2 - src/Resources/Locales/pt_BR.axaml | 2 - src/Resources/Locales/ru_RU.axaml | 2 - src/Resources/Locales/zh_CN.axaml | 2 - src/Resources/Locales/zh_TW.axaml | 2 - src/ViewModels/InteractiveRebase.cs | 2 + src/Views/InteractiveRebase.axaml | 22 +++---- src/Views/InteractiveRebase.axaml.cs | 90 +++++++++++++++++++++------- 10 files changed, 83 insertions(+), 45 deletions(-) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 3440d12c..84e93505 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -359,8 +359,6 @@ Interaktiver Rebase Ziel Branch: Auf: - Hochschieben - Runterschieben Source Git FEHLER INFO diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index bd2efd9c..5aee1ab1 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -357,8 +357,6 @@ Interactive Rebase Target Branch: On: - Move Up - Move Down Source Git ERROR NOTICE diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index c047e7d7..82c7db7e 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -345,8 +345,6 @@ Interactive Rebase Target Branch: On: - Move Up - Move Down Source Git ERROR NOTICE diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index 57ce05ef..191d19a1 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -340,8 +340,6 @@ Rebase Interativo Ramo Alvo: Em: - Mover Para Cima - Mover Para Baixo Source Git ERRO AVISO diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index 60abd646..e7bfd8fd 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -359,8 +359,6 @@ Интерактивное перемещение Целевая ветка: На: - Вверх - Вниз Source Git ОШИБКА УВЕДОМЛЕНИЕ diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 78e455d3..89b04ade 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -360,8 +360,6 @@ 交互式变基 目标分支 : 起始提交 : - 向上移动 - 向下移动 Source Git 出错了 系统提示 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 64ae8b06..d5817d11 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -360,8 +360,6 @@ 互動式重定基底 目標分支: 起始提交: - 向上移動 - 向下移動 Source Git 發生錯誤 系統提示 diff --git a/src/ViewModels/InteractiveRebase.cs b/src/ViewModels/InteractiveRebase.cs index 0c8838e0..355671c7 100644 --- a/src/ViewModels/InteractiveRebase.cs +++ b/src/ViewModels/InteractiveRebase.cs @@ -140,6 +140,7 @@ namespace SourceGit.ViewModels var prev = Items[idx - 1]; Items.RemoveAt(idx - 1); Items.Insert(idx, prev); + SelectedItem = item; } } @@ -151,6 +152,7 @@ namespace SourceGit.ViewModels var next = Items[idx + 1]; Items.RemoveAt(idx + 1); Items.Insert(idx, next); + SelectedItem = item; } } diff --git a/src/Views/InteractiveRebase.axaml b/src/Views/InteractiveRebase.axaml index a8f9d360..e1161a2b 100644 --- a/src/Views/InteractiveRebase.axaml +++ b/src/Views/InteractiveRebase.axaml @@ -59,14 +59,14 @@ - +