From 59e3e4c63557eb92a5001b69adfa7723144a66c7 Mon Sep 17 00:00:00 2001 From: GadflyFang Date: Mon, 13 Jan 2025 12:07:24 +0800 Subject: [PATCH 01/25] docs: Update README.md with APT source config changes (#897) - Update APT source configuration to include architecture-specific settings. Signed-off-by: Gadfly --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index acbf22ff..9644d186 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ For **Linux** users: `deb` how to: ```shell curl https://codeberg.org/api/packages/yataro/debian/repository.key | sudo tee /etc/apt/keyrings/sourcegit.asc - echo "deb [signed-by=/etc/apt/keyrings/sourcegit.asc] https://codeberg.org/api/packages/yataro/debian generic main" | sudo tee /etc/apt/sources.list.d/sourcegit.list + echo "deb [signed-by=/etc/apt/keyrings/sourcegit.asc, arch=amd64,arm64] https://codeberg.org/api/packages/yataro/debian generic main" | sudo tee /etc/apt/sources.list.d/sourcegit.list sudo apt update sudo apt install sourcegit ``` From 10d8d3b2efedfcaf358aa9b29b444ae25d460024 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 13 Jan 2025 14:42:07 +0800 Subject: [PATCH 02/25] refactor: branch compare --- src/Resources/Locales/de_DE.axaml | 1 - src/Resources/Locales/en_US.axaml | 1 - src/Resources/Locales/es_ES.axaml | 1 - src/Resources/Locales/fr_FR.axaml | 1 - src/Resources/Locales/it_IT.axaml | 1 - src/Resources/Locales/pt_BR.axaml | 1 - src/Resources/Locales/ru_RU.axaml | 1 - src/Resources/Locales/zh_CN.axaml | 1 - src/Resources/Locales/zh_TW.axaml | 1 - src/ViewModels/Repository.cs | 89 ++++++++++--------------------- 10 files changed, 27 insertions(+), 71 deletions(-) diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 96dced8d..db4fee87 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -50,7 +50,6 @@ Blame BLAME WIRD BEI DIESER DATEI NICHT UNTERSTÜTZT!!! Auschecken von ${0}$... - Mit Branch vergleichen Mit HEAD vergleichen Mit Worktree vergleichen Branch-Namen kopieren diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 1b0059a5..d06f438d 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -47,7 +47,6 @@ Blame BLAME ON THIS FILE IS NOT SUPPORTED!!! Checkout ${0}$... - Compare with Branch Compare with HEAD Compare with Worktree Copy Branch Name diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index 7f6bad97..74b2f224 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -50,7 +50,6 @@ Blame ¡BLAME EN ESTE ARCHIVO NO SOPORTADO! Checkout ${0}$... - Comparar con Rama Comparar con HEAD Comparar con Worktree Copiar Nombre de Rama diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index 1bfd5284..e4bb9c26 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -50,7 +50,6 @@ Blâme LE BLÂME SUR CE FICHIER N'EST PAS SUPPORTÉ!!! Récupérer ${0}$... - Comparer avec la branche Comparer avec HEAD Comparer avec le worktree Copier le nom de la branche diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index e63a4737..72e2aa28 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -50,7 +50,6 @@ Attribuisci L'ATTRIBUZIONE SU QUESTO FILE NON È SUPPORTATA!!! Checkout ${0}$... - Confronta con Branch Confronta con HEAD Confronta con Worktree Copia Nome Branch diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index 5d29caca..8b17bdaf 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -75,7 +75,6 @@ Blame BLAME NESTE ARQUIVO NÃO É SUPORTADO!!! Checkout ${0}$... - Comparar com Branch Comparar com HEAD Comparar com Worktree Copiar Nome do Branch diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index 725f378c..75650a28 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -50,7 +50,6 @@ Расследование РАССЛЕДОВАНИЕ В ЭТОМ ФАЙЛЕ НЕ ПОДДЕРЖИВАЕТСЯ!!! Проверить ${0}$... - Сравнить с веткой Сравнить с ГОЛОВОЙ (HEAD) Сравнить с рабочим каталогом Копировать имя ветки diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 81d0d80f..b5541376 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -50,7 +50,6 @@ 逐行追溯(blame) 选中文件不支持该操作!!! 检出(checkout) ${0}$... - 与其他分支对比 与当前HEAD比较 与本地工作树比较 复制分支名 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 4fb4f375..d2395e58 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -50,7 +50,6 @@ 逐行溯源 (blame) 所選擇的檔案不支援該操作! 簽出 (checkout) ${0}$... - 與其他分支比較 與目前 HEAD 比較 與本機工作區比較 複製分支名稱 diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index c317c2b8..209c66e1 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.Intrinsics.Arm; using System.Text; using System.Text.Json; using System.Threading; @@ -1463,13 +1464,6 @@ namespace SourceGit.ViewModels } menu.Items.Add(push); - - var compareWithBranch = CreateMenuItemToCompareBranches(branch); - if (compareWithBranch != null) - { - menu.Items.Add(new MenuItem() { Header = "-" }); - menu.Items.Add(compareWithBranch); - } } else { @@ -1540,6 +1534,19 @@ namespace SourceGit.ViewModels menu.Items.Add(merge); menu.Items.Add(rebase); + var compareWithHead = new MenuItem(); + compareWithHead.Header = App.Text("BranchCM.CompareWithHead"); + compareWithHead.Icon = App.CreateMenuIcon("Icons.Compare"); + compareWithHead.Click += (_, _) => + { + App.OpenDialog(new Views.BranchCompare() + { + DataContext = new BranchCompare(_fullpath, branch, _currentBranch) + }); + }; + menu.Items.Add(new MenuItem() { Header = "-" }); + menu.Items.Add(compareWithHead); + if (_localChangesCount > 0) { var compareWithWorktree = new MenuItem(); @@ -1556,18 +1563,8 @@ namespace SourceGit.ViewModels _histories.DetailContext = new RevisionCompare(_fullpath, target, null); } }; - menu.Items.Add(new MenuItem() { Header = "-" }); menu.Items.Add(compareWithWorktree); } - - var compareWithBranch = CreateMenuItemToCompareBranches(branch); - if (compareWithBranch != null) - { - if (_localChangesCount == 0) - menu.Items.Add(new MenuItem() { Header = "-" }); - - menu.Items.Add(compareWithBranch); - } } var detect = Commands.GitFlow.DetectType(_fullpath, _branches, branch.Name); @@ -1813,7 +1810,19 @@ namespace SourceGit.ViewModels menu.Items.Add(new MenuItem() { Header = "-" }); } - var hasCompare = false; + var compareWithHead = new MenuItem(); + compareWithHead.Header = App.Text("BranchCM.CompareWithHead"); + compareWithHead.Icon = App.CreateMenuIcon("Icons.Compare"); + compareWithHead.Click += (_, _) => + { + App.OpenDialog(new Views.BranchCompare() + { + DataContext = new BranchCompare(_fullpath, branch, _currentBranch) + }); + }; + menu.Items.Add(new MenuItem() { Header = "-" }); + menu.Items.Add(compareWithHead); + if (_localChangesCount > 0) { var compareWithWorktree = new MenuItem(); @@ -1831,19 +1840,8 @@ namespace SourceGit.ViewModels } }; menu.Items.Add(compareWithWorktree); - hasCompare = true; } - var compareWithBranch = CreateMenuItemToCompareBranches(branch); - if (compareWithBranch != null) - { - menu.Items.Add(compareWithBranch); - hasCompare = true; - } - - if (hasCompare) - menu.Items.Add(new MenuItem() { Header = "-" }); - var delete = new MenuItem(); delete.Header = new Views.NameHighlightedTextBlock("BranchCM.Delete", name); delete.Icon = App.CreateMenuIcon("Icons.Clear"); @@ -2078,39 +2076,6 @@ namespace SourceGit.ViewModels return menu; } - private MenuItem CreateMenuItemToCompareBranches(Models.Branch branch) - { - if (_branches.Count == 1) - return null; - - var compare = new MenuItem(); - compare.Header = App.Text("BranchCM.CompareWithBranch"); - compare.Icon = App.CreateMenuIcon("Icons.Compare"); - - foreach (var b in _branches) - { - if (b.FullName != branch.FullName) - { - var dup = b; - var target = new MenuItem(); - target.Header = b.FriendlyName; - target.Icon = App.CreateMenuIcon(b.IsCurrent ? "Icons.Check" : "Icons.Branch"); - target.Click += (_, e) => - { - App.OpenDialog(new Views.BranchCompare() - { - DataContext = new BranchCompare(_fullpath, branch, dup) - }); - e.Handled = true; - }; - - compare.Items.Add(target); - } - } - - return compare; - } - private LauncherPage GetOwnerPage() { var launcher = App.GetLauncer(); From 88e64a4f3169eeb8b6dccf4ce9ff4327af6759e0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 13 Jan 2025 06:42:23 +0000 Subject: [PATCH 03/25] doc: Update translation status and missing keys --- README.md | 2 +- TRANSLATION.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9644d186..bc1581b6 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ ## Translation Status -[![en_US](https://img.shields.io/badge/en__US-100%25-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-97.55%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-100.00%25-brightgreen)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-94.69%25-yellow)](TRANSLATION.md) [![it__IT](https://img.shields.io/badge/it__IT-93.33%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-94.42%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-100.00%25-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-100.00%25-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-100.00%25-brightgreen)](TRANSLATION.md) +[![en_US](https://img.shields.io/badge/en__US-100%25-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-97.55%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-100.00%25-brightgreen)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-94.69%25-yellow)](TRANSLATION.md) [![it__IT](https://img.shields.io/badge/it__IT-93.32%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-94.41%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-100.00%25-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-100.00%25-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-100.00%25-brightgreen)](TRANSLATION.md) > [!NOTE] > You can find the missing keys in [TRANSLATION.md](TRANSLATION.md) diff --git a/TRANSLATION.md b/TRANSLATION.md index 45b0e171..b2f2b987 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -83,7 +83,7 @@ -### it_IT.axaml: 93.33% +### it_IT.axaml: 93.32%
@@ -141,7 +141,7 @@
-### pt_BR.axaml: 94.42% +### pt_BR.axaml: 94.41%
From b10e084c5447aa91cb601a07d7ecf879f2c8d82c Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 13 Jan 2025 14:47:18 +0800 Subject: [PATCH 04/25] ux: context menu separator --- src/ViewModels/Repository.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 209c66e1..b747556c 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Runtime.Intrinsics.Arm; using System.Text; using System.Text.Json; using System.Threading; @@ -1820,7 +1819,6 @@ namespace SourceGit.ViewModels DataContext = new BranchCompare(_fullpath, branch, _currentBranch) }); }; - menu.Items.Add(new MenuItem() { Header = "-" }); menu.Items.Add(compareWithHead); if (_localChangesCount > 0) @@ -1841,6 +1839,7 @@ namespace SourceGit.ViewModels }; menu.Items.Add(compareWithWorktree); } + menu.Items.Add(new MenuItem() { Header = "-" }); var delete = new MenuItem(); delete.Header = new Views.NameHighlightedTextBlock("BranchCM.Delete", name); From 458a1ea83c3fec8b72f04f98b19dd2574ccef4c2 Mon Sep 17 00:00:00 2001 From: wl2776 Date: Sun, 12 Jan 2025 23:33:13 -0800 Subject: [PATCH 05/25] feature: Exit on Ctrl+Q (#898) --- src/Views/Hotkeys.axaml | 5 ++++- src/Views/Launcher.axaml | 1 + src/Views/Launcher.axaml.cs | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Views/Hotkeys.axaml b/src/Views/Hotkeys.axaml index 1ce4bb9a..67293b50 100644 --- a/src/Views/Hotkeys.axaml +++ b/src/Views/Hotkeys.axaml @@ -45,7 +45,7 @@ FontSize="{Binding Source={x:Static vm:Preferences.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Increase}}" Margin="0,0,0,8"/> - + @@ -66,6 +66,9 @@ + + + + diff --git a/src/Views/Launcher.axaml.cs b/src/Views/Launcher.axaml.cs index 39abb71b..832cca80 100644 --- a/src/Views/Launcher.axaml.cs +++ b/src/Views/Launcher.axaml.cs @@ -146,6 +146,12 @@ namespace SourceGit.Views return; } + if (e.Key == Key.Q) { + App.Quit(0); + e.Handled = true; + return; + } + if ((OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Alt) && e.Key == Key.Right) || (!OperatingSystem.IsMacOS() && !e.KeyModifiers.HasFlag(KeyModifiers.Shift) && e.Key == Key.Tab)) { From 632222a776b1a879ffc63e46b98afbf87d0075bb Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 13 Jan 2025 15:37:55 +0800 Subject: [PATCH 06/25] ux: add icon for quit menu item --- src/Resources/Icons.axaml | 1 + src/Views/Launcher.axaml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Resources/Icons.axaml b/src/Resources/Icons.axaml index c0c9d8ff..c7e02431 100644 --- a/src/Resources/Icons.axaml +++ b/src/Resources/Icons.axaml @@ -86,6 +86,7 @@ m186 532 287 0 0 287c0 11 9 20 20 20s20-9 20-20l0-287 287 0c11 0 20-9 20-20s-9-20-20-20l-287 0 0-287c0-11-9-20-20-20s-20 9-20 20l0 287-287 0c-11 0-20 9-20 20s9 20 20 20z M432 0h160c27 0 48 21 48 48v336h175c36 0 53 43 28 68L539 757c-15 15-40 15-55 0L180 452c-25-25-7-68 28-68H384V48c0-27 21-48 48-48zm592 752v224c0 27-21 48-48 48H48c-27 0-48-21-48-48V752c0-27 21-48 48-48h293l98 98c40 40 105 40 145 0l98-98H976c27 0 48 21 48 48zm-248 176c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40zm128 0c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40z M592 768h-160c-27 0-48-21-48-48V384h-175c-36 0-53-43-28-68L485 11c15-15 40-15 55 0l304 304c25 25 7 68-28 68H640v336c0 27-21 48-48 48zm432-16v224c0 27-21 48-48 48H48c-27 0-48-21-48-48V752c0-27 21-48 48-48h272v16c0 62 50 112 112 112h160c62 0 112-50 112-112v-16h272c27 0 48 21 48 48zm-248 176c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40zm128 0c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40z + M563 555c0 28-23 51-51 51-28 0-51-23-51-51L461 113c0-28 23-51 51-51s51 23 51 51L563 555 563 555zM85 535c0-153 81-287 201-362 24-15 55-8 70 16C371 214 363 245 340 260 248 318 187 419 187 535c0 180 146 325 325 325 180-0 325-146 325-325 0-119-64-223-160-280-24-14-32-46-18-70 14-24 46-32 70-18 125 74 210 211 210 367 0 236-191 427-427 427C276 963 85 772 85 535 M277 85a149 149 0 00-43 292v230a32 32 0 0064 0V555h267A160 160 0 00725 395v-12a149 149 0 10-64-5v17a96 96 0 01-96 96H299V383A149 149 0 00277 85zM228 720a32 32 0 00-37-52 150 150 0 00-53 68 32 32 0 1060 23 85 85 0 0130-39zm136-52a32 32 0 00-37 52 86 86 0 0130 39 32 32 0 1060-23 149 149 0 00-53-68zM204 833a32 32 0 10-55 32 149 149 0 0063 58 32 32 0 0028-57 85 85 0 01-36-33zm202 32a32 32 0 00-55-32 85 85 0 01-36 33 32 32 0 0028 57 149 149 0 0063-58z M467 556c0-0 0-1 0-1C467 555 467 556 467 556zM467 556c0-0 0-0 0-0C467 556 467 556 467 556zM467 556c-0 0-0 0-0 0C467 557 467 557 467 556zM468 549C468 532 468 541 468 549L468 549zM468 549c0 1-0 1-0 2C468 551 468 550 468 549zM468 552c-0 1-0 2-0 3C467 554 468 553 468 552zM736 549C736 532 736 541 736 549L736 549zM289 378l0 179 89 0c-1 80-89 89-89 89l45 45c0 0 129-15 134-134L467 378 289 378zM959 244l0 536c0 99-80 179-179 179L244 959c-99 0-179-80-179-179L65 244c0-99 80-179 179-179l536 0C879 65 959 145 959 244zM869 289c0-74-60-134-134-134L289 155c-74 0-134 60-134 134l0 447c0 74 60 134 134 134l447 0c74 0 134-60 134-134L869 289zM557 557l89 0c-1 80-89 89-89 89l45 45c0 0 129-15 134-134L735 378 557 378 557 557z m224 154a166 166 0 00-166 166v192a166 166 0 00166 166h64v-76h-64a90 90 0 01-90-90v-192a90 90 0 0190-90h320a90 90 0 0190 90v192a90 90 0 01-90 90h-128v77h128a166 166 0 00166-167v-192a166 166 0 00-166-166h-320zm166 390a90 90 0 0190-90h128v-76h-128a166 166 0 00-166 166v192a166 166 0 00166 166h320a166 166 0 00166-166v-192a166 166 0 00-166-166h-64v77h64a90 90 0 0190 90v192a90 90 0 01-90 90h-320a90 90 0 01-90-90v-192z diff --git a/src/Views/Launcher.axaml b/src/Views/Launcher.axaml index 55c407b2..bfabf6e5 100644 --- a/src/Views/Launcher.axaml +++ b/src/Views/Launcher.axaml @@ -62,7 +62,11 @@ - + + + + + From 5f4c1bb984c1f2a76d241a0536c30de03b557b27 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 13 Jan 2025 17:37:23 +0800 Subject: [PATCH 07/25] enhance: do not show `Initialize Repository` popup for bare repositories (#891) --- src/ViewModels/Welcome.cs | 31 ++++++++++++++++++++++++++ src/Views/Welcome.axaml.cs | 36 ++----------------------------- src/Views/WelcomeToolbar.axaml.cs | 27 +---------------------- 3 files changed, 34 insertions(+), 60 deletions(-) diff --git a/src/ViewModels/Welcome.cs b/src/ViewModels/Welcome.cs index e6d64469..5c9c9380 100644 --- a/src/ViewModels/Welcome.cs +++ b/src/ViewModels/Welcome.cs @@ -83,6 +83,37 @@ namespace SourceGit.ViewModels } } + public void OpenOrInitRepository(string path, RepositoryNode parent, bool bMoveExistedNode) + { + if (!Directory.Exists(path)) + { + if (File.Exists(path)) + path = Path.GetDirectoryName(path); + else + return; + } + + var isBare = new Commands.IsBareRepository(path).Result(); + if (isBare) + { + App.RaiseException(string.Empty, $"'{path}' is a bare repository, which is not supported by SourceGit!"); + return; + } + + var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd(); + if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut)) + { + InitRepository(path, parent, test.StdErr); + return; + } + + var node = Preferences.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), parent, bMoveExistedNode); + Refresh(); + + var launcher = App.GetLauncer(); + launcher?.OpenRepositoryInTab(node, launcher.ActivePage); + } + public void InitRepository(string path, RepositoryNode parent, string reason) { if (!Preferences.Instance.IsGitConfigured()) diff --git a/src/Views/Welcome.axaml.cs b/src/Views/Welcome.axaml.cs index ffb8332b..3ab11782 100644 --- a/src/Views/Welcome.axaml.cs +++ b/src/Views/Welcome.axaml.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using Avalonia; using Avalonia.Controls; @@ -197,7 +196,7 @@ namespace SourceGit.Views { foreach (var item in items) { - OpenOrInitRepository(item.Path.LocalPath); + ViewModels.Welcome.Instance.OpenOrInitRepository(item.Path.LocalPath, null, true); break; } } @@ -261,7 +260,7 @@ namespace SourceGit.Views { foreach (var item in items) { - OpenOrInitRepository(item.Path.LocalPath, to); + ViewModels.Welcome.Instance.OpenOrInitRepository(item.Path.LocalPath, to, true); break; } } @@ -290,37 +289,6 @@ namespace SourceGit.Views } } - private void OpenOrInitRepository(string path, ViewModels.RepositoryNode parent = null) - { - if (!Directory.Exists(path)) - { - if (File.Exists(path)) - path = Path.GetDirectoryName(path); - else - return; - } - - var isBare = new Commands.IsBareRepository(path).Result(); - if (isBare) - { - App.RaiseException(string.Empty, $"'{path}' is a bare repository, which is not supported by SourceGit!"); - return; - } - - var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd(); - if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut)) - { - ViewModels.Welcome.Instance.InitRepository(path, parent, test.StdErr); - return; - } - - var node = ViewModels.Preferences.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), parent, true); - ViewModels.Welcome.Instance.Refresh(); - - var launcher = this.FindAncestorOfType()?.DataContext as ViewModels.Launcher; - launcher?.OpenRepositoryInTab(node, launcher.ActivePage); - } - private bool _pressedTreeNode = false; private Point _pressedTreeNodePosition = new Point(); private bool _startDragTreeNode = false; diff --git a/src/Views/WelcomeToolbar.axaml.cs b/src/Views/WelcomeToolbar.axaml.cs index f1ff14f3..9e170c1a 100644 --- a/src/Views/WelcomeToolbar.axaml.cs +++ b/src/Views/WelcomeToolbar.axaml.cs @@ -4,7 +4,6 @@ using System.IO; using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Platform.Storage; -using Avalonia.VisualTree; namespace SourceGit.Views { @@ -36,7 +35,7 @@ namespace SourceGit.Views { var selected = await topLevel.StorageProvider.OpenFolderPickerAsync(options); if (selected.Count == 1) - OpenOrInitRepository(selected[0].Path.LocalPath); + ViewModels.Welcome.Instance.OpenOrInitRepository(selected[0].Path.LocalPath, null, false); } catch (Exception exception) { @@ -45,30 +44,6 @@ namespace SourceGit.Views e.Handled = true; } - - private void OpenOrInitRepository(string path, ViewModels.RepositoryNode parent = null) - { - if (!Directory.Exists(path)) - { - if (File.Exists(path)) - path = Path.GetDirectoryName(path); - else - return; - } - - var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd(); - if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut)) - { - ViewModels.Welcome.Instance.InitRepository(path, parent, test.StdErr); - return; - } - - var node = ViewModels.Preferences.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), parent, false); - ViewModels.Welcome.Instance.Refresh(); - - var launcher = this.FindAncestorOfType()?.DataContext as ViewModels.Launcher; - launcher?.OpenRepositoryInTab(node, launcher.ActivePage); - } } } From 011f5258adc4a886a76bdb2f0ecaac1412cf29bf Mon Sep 17 00:00:00 2001 From: Mat Date: Tue, 14 Jan 2025 03:18:56 +0100 Subject: [PATCH 08/25] fix: LFS locks do not show if user name contains `.` character (#902) --- src/Commands/LFS.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/LFS.cs b/src/Commands/LFS.cs index c9ab7b41..2b7d1de4 100644 --- a/src/Commands/LFS.cs +++ b/src/Commands/LFS.cs @@ -7,7 +7,7 @@ namespace SourceGit.Commands { public partial class LFS { - [GeneratedRegex(@"^(.+)\s+(\w+)\s+\w+:(\d+)$")] + [GeneratedRegex(@"^(.+)\s+([\w.]+)\s+\w+:(\d+)$")] private static partial Regex REG_LOCK(); class SubCmd : Command From 99b7086cd04feba2573c0c822f6be881f2f795ed Mon Sep 17 00:00:00 2001 From: Vixb Date: Tue, 14 Jan 2025 10:19:27 +0800 Subject: [PATCH 09/25] doc: update default path for windows (#901) (cherry picked from commit 4456366ea63b277665d7250709928deb1e563675) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc1581b6..2973a65c 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ This software creates a folder `$"{System.Environment.SpecialFolder.ApplicationD | OS | PATH | |---------|-----------------------------------------------------| -| Windows | `C:\Users\USER_NAME\AppData\Roaming\SourceGit` | +| Windows | `%APPDATA%\SourceGit` | | Linux | `${HOME}/.config/SourceGit` or `${HOME}/.sourcegit` | | macOS | `${HOME}/Library/Application Support/SourceGit` | From d8168c3ba68eeae412c82ed6620087d4251a9307 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 14 Jan 2025 16:14:19 +0800 Subject: [PATCH 10/25] ux: submodule alignment --- src/Views/Repository.axaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index d928cc20..d935d754 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -313,7 +313,7 @@ - + Date: Tue, 14 Jan 2025 17:10:06 +0800 Subject: [PATCH 11/25] refactor: do not run `git add` for untracked file while stashing local changes (#903) --- src/Commands/QueryStashChanges.cs | 60 ------------------------------- src/Commands/QueryStashes.cs | 22 +++++++++--- src/Commands/Stash.cs | 14 ++++++-- src/Models/Stash.cs | 3 ++ src/ViewModels/StashChanges.cs | 39 +------------------- src/ViewModels/StashesPage.cs | 26 ++++++++++++-- 6 files changed, 56 insertions(+), 108 deletions(-) delete mode 100644 src/Commands/QueryStashChanges.cs diff --git a/src/Commands/QueryStashChanges.cs b/src/Commands/QueryStashChanges.cs deleted file mode 100644 index 3b8d2db6..00000000 --- a/src/Commands/QueryStashChanges.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace SourceGit.Commands -{ - public partial class QueryStashChanges : Command - { - [GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")] - private static partial Regex REG_FORMAT(); - - public QueryStashChanges(string repo, string sha) - { - WorkingDirectory = repo; - Context = repo; - Args = $"diff --name-status --pretty=format: {sha}^ {sha}"; - } - - public List Result() - { - Exec(); - return _changes; - } - - protected override void OnReadline(string line) - { - var match = REG_FORMAT().Match(line); - if (!match.Success) - return; - - var change = new Models.Change() { Path = match.Groups[2].Value }; - var status = match.Groups[1].Value; - - switch (status[0]) - { - case 'M': - change.Set(Models.ChangeState.Modified); - _changes.Add(change); - break; - case 'A': - change.Set(Models.ChangeState.Added); - _changes.Add(change); - break; - case 'D': - change.Set(Models.ChangeState.Deleted); - _changes.Add(change); - break; - case 'R': - change.Set(Models.ChangeState.Renamed); - _changes.Add(change); - break; - case 'C': - change.Set(Models.ChangeState.Copied); - _changes.Add(change); - break; - } - } - - private readonly List _changes = new List(); - } -} diff --git a/src/Commands/QueryStashes.cs b/src/Commands/QueryStashes.cs index 6d089f8e..ccf601c5 100644 --- a/src/Commands/QueryStashes.cs +++ b/src/Commands/QueryStashes.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace SourceGit.Commands { @@ -8,7 +9,7 @@ namespace SourceGit.Commands { WorkingDirectory = repo; Context = repo; - Args = "stash list --pretty=format:%H%n%ct%n%gd%n%s"; + Args = "stash list --pretty=format:%H%n%P%n%ct%n%gd%n%s"; } public List Result() @@ -26,21 +27,32 @@ namespace SourceGit.Commands _stashes.Add(_current); break; case 1: - _current.Time = ulong.Parse(line); + ParseParent(line); break; case 2: - _current.Name = line; + _current.Time = ulong.Parse(line); break; case 3: + _current.Name = line; + break; + case 4: _current.Message = line; break; } _nextLineIdx++; - if (_nextLineIdx > 3) + if (_nextLineIdx > 4) _nextLineIdx = 0; } + private void ParseParent(string data) + { + if (data.Length < 8) + return; + + _current.Parents.AddRange(data.Split(separator: ' ', options: StringSplitOptions.RemoveEmptyEntries)); + } + private readonly List _stashes = new List(); private Models.Stash _current = null; private int _nextLineIdx = 0; diff --git a/src/Commands/Stash.cs b/src/Commands/Stash.cs index 40c917dd..cee79886 100644 --- a/src/Commands/Stash.cs +++ b/src/Commands/Stash.cs @@ -11,9 +11,19 @@ namespace SourceGit.Commands Context = repo; } - public bool Push(string message) + public bool Push(string message, bool includeUntracked = true, bool keepIndex = false) { - Args = $"stash push -m \"{message}\""; + var builder = new StringBuilder(); + builder.Append("stash push "); + if (includeUntracked) + builder.Append("--include-untracked "); + if (keepIndex) + builder.Append("--keep-index "); + builder.Append("-m \""); + builder.Append(message); + builder.Append("\""); + + Args = builder.ToString(); return Exec(); } diff --git a/src/Models/Stash.cs b/src/Models/Stash.cs index 3d395a84..8dca3bdb 100644 --- a/src/Models/Stash.cs +++ b/src/Models/Stash.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace SourceGit.Models { @@ -6,8 +7,10 @@ namespace SourceGit.Models { public string Name { get; set; } = ""; public string SHA { get; set; } = ""; + public List Parents { get; set; } = []; public ulong Time { get; set; } = 0; public string Message { get; set; } = ""; + public bool HasUntracked => Parents.Count == 3; public string TimeStr => DateTime.UnixEpoch.AddSeconds(Time).ToLocalTime().ToString(DateTimeFormat.Actived.DateTime); } diff --git a/src/ViewModels/StashChanges.cs b/src/ViewModels/StashChanges.cs index 48c9478e..fd937bdd 100644 --- a/src/ViewModels/StashChanges.cs +++ b/src/ViewModels/StashChanges.cs @@ -76,14 +76,11 @@ namespace SourceGit.ViewModels } else { - if (IncludeUntracked) - AddUntracked(_changes); - succ = StashWithChanges(_changes); + succ = new Commands.Stash(_repo.FullPath).Push(Message, IncludeUntracked, KeepIndex); } } else { - AddUntracked(_changes); succ = StashWithChanges(_changes); } @@ -97,40 +94,6 @@ namespace SourceGit.ViewModels }); } - private void AddUntracked(List changes) - { - var toBeAdded = new List(); - foreach (var c in changes) - { - if (c.WorkTree == Models.ChangeState.Added || c.WorkTree == Models.ChangeState.Untracked) - toBeAdded.Add(c); - } - - if (toBeAdded.Count == 0) - return; - - if (Native.OS.GitVersion >= Models.GitVersions.ADD_WITH_PATHSPECFILE) - { - var paths = new List(); - foreach (var c in toBeAdded) - paths.Add(c.Path); - - var tmpFile = Path.GetTempFileName(); - File.WriteAllLines(tmpFile, paths); - new Commands.Add(_repo.FullPath, tmpFile).Exec(); - File.Delete(tmpFile); - } - else - { - for (int i = 0; i < toBeAdded.Count; i += 10) - { - var count = Math.Min(10, toBeAdded.Count - i); - var step = toBeAdded.GetRange(i, count); - new Commands.Add(_repo.FullPath, step).Exec(); - } - } - } - private bool StashWithChanges(List changes) { if (changes.Count == 0) diff --git a/src/ViewModels/StashesPage.cs b/src/ViewModels/StashesPage.cs index 3ddb2b65..e5755a91 100644 --- a/src/ViewModels/StashesPage.cs +++ b/src/ViewModels/StashesPage.cs @@ -57,8 +57,25 @@ namespace SourceGit.ViewModels { Task.Run(() => { - var changes = new Commands.QueryStashChanges(_repo.FullPath, value.SHA).Result(); - Dispatcher.UIThread.Invoke(() => Changes = changes); + var changes = new Commands.CompareRevisions(_repo.FullPath, $"{value.SHA}^", value.SHA).Result(); + var untracked = new HashSet(); + if (value.HasUntracked) + { + var untrackedChanges = new Commands.CompareRevisions(_repo.FullPath, "4b825dc642cb6eb9a060e54bf8d69288fbee4904", value.Parents[2]).Result(); + foreach (var c in untrackedChanges) + { + untracked.Add(c.Path); + changes.Add(c); + } + } + + changes.Sort((l, r) => Models.NumericSort.Compare(l.Path, r.Path)); + + Dispatcher.UIThread.Invoke(() => + { + Changes = changes; + _untrackedChanges = untracked; + }); }); } } @@ -84,8 +101,10 @@ namespace SourceGit.ViewModels { if (value == null) DiffContext = null; + else if (_untrackedChanges.Contains(value.Path)) + DiffContext = new DiffContext(_repo.FullPath, new Models.DiffOption("4b825dc642cb6eb9a060e54bf8d69288fbee4904", _selectedStash.Parents[2], value), _diffContext); else - DiffContext = new DiffContext(_repo.FullPath, new Models.DiffOption($"{_selectedStash.SHA}^", _selectedStash.SHA, value), _diffContext); + DiffContext = new DiffContext(_repo.FullPath, new Models.DiffOption(_selectedStash.Parents[0], _selectedStash.SHA, value), _diffContext); } } } @@ -254,6 +273,7 @@ namespace SourceGit.ViewModels private List _visibleStashes = new List(); private string _searchFilter = string.Empty; private Models.Stash _selectedStash = null; + private HashSet _untrackedChanges = new HashSet(); private List _changes = null; private Models.Change _selectedChange = null; private DiffContext _diffContext = null; From b9b52205906df9bfe33b5c3d7698fd1246888d9e Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 13 Jan 2025 19:49:50 +0800 Subject: [PATCH 12/25] feature: `bare` repository support --- src/ViewModels/CreateBranch.cs | 7 ++++- src/ViewModels/Launcher.cs | 21 +++++++------- src/ViewModels/Repository.cs | 18 ++++++++++++ src/ViewModels/ScanRepositories.cs | 25 +++++++++++++---- src/ViewModels/Welcome.cs | 22 +++++++-------- src/Views/CreateBranch.axaml | 44 ++++++++++++++++-------------- 6 files changed, 89 insertions(+), 48 deletions(-) diff --git a/src/ViewModels/CreateBranch.cs b/src/ViewModels/CreateBranch.cs index 64806a49..b67a453a 100644 --- a/src/ViewModels/CreateBranch.cs +++ b/src/ViewModels/CreateBranch.cs @@ -31,6 +31,11 @@ namespace SourceGit.ViewModels set => _repo.Settings.CheckoutBranchOnCreateBranch = value; } + public bool IsBareRepository + { + get => _repo.IsBare; + } + public CreateBranch(Repository repo, Models.Branch branch) { _repo = repo; @@ -84,7 +89,7 @@ namespace SourceGit.ViewModels return Task.Run(() => { var succ = false; - if (CheckoutAfterCreated) + if (CheckoutAfterCreated && !_repo.IsBare) { var changes = new Commands.CountLocalChangesWithoutUntracked(_repo.FullPath).Result(); var needPopStash = false; diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index 57a1c404..6761eccf 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -280,19 +280,20 @@ namespace SourceGit.ViewModels return; } - var gitDir = new Commands.QueryGitDir(node.Id).Result(); - if (string.IsNullOrEmpty(gitDir)) + var isBare = new Commands.IsBareRepository(node.Id).Result(); + var gitDir = node.Id; + if (!isBare) { - var ctx = page == null ? ActivePage.Node.Id : page.Node.Id; - App.RaiseException(ctx, "Given path is not a valid git repository!"); - return; + gitDir = new Commands.QueryGitDir(node.Id).Result(); + if (string.IsNullOrEmpty(gitDir)) + { + var ctx = page == null ? ActivePage.Node.Id : page.Node.Id; + App.RaiseException(ctx, "Given path is not a valid git repository!"); + return; + } } - var repo = new Repository() - { - FullPath = node.Id, - GitDir = gitDir, - }; + var repo = new Repository(isBare, node.Id, gitDir); repo.Open(); if (page == null) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index b747556c..6dfa67ca 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -18,6 +18,11 @@ namespace SourceGit.ViewModels { public class Repository : ObservableObject, Models.IRepository { + public bool IsBare + { + get; + } + public string FullPath { get => _fullpath; @@ -448,6 +453,13 @@ namespace SourceGit.ViewModels private set => SetProperty(ref _isAutoFetching, value); } + public Repository(bool isBare, string path, string gitDir) + { + IsBare = isBare; + FullPath = path; + GitDir = gitDir; + } + public void Open() { var settingsFile = Path.Combine(_gitDir, "sourcegit.settings"); @@ -995,6 +1007,9 @@ namespace SourceGit.ViewModels public void RefreshWorkingCopyChanges() { + if (IsBare) + return; + var changes = new Commands.QueryLocalChanges(_fullpath, _settings.IncludeUntrackedInLocalChanges).Result(); if (_workingCopy == null) return; @@ -1010,6 +1025,9 @@ namespace SourceGit.ViewModels public void RefreshStashes() { + if (IsBare) + return; + var stashes = new Commands.QueryStashes(_fullpath).Result(); Dispatcher.UIThread.Invoke(() => { diff --git a/src/ViewModels/ScanRepositories.cs b/src/ViewModels/ScanRepositories.cs index 5c023587..8d14e36e 100644 --- a/src/ViewModels/ScanRepositories.cs +++ b/src/ViewModels/ScanRepositories.cs @@ -34,7 +34,7 @@ namespace SourceGit.ViewModels watch.Start(); var rootDir = new DirectoryInfo(RootDir); - var founded = new List(); + var founded = new List(); GetUnmanagedRepositories(rootDir, founded, new EnumerationOptions() { AttributesToSkip = FileAttributes.Hidden | FileAttributes.System, @@ -47,16 +47,16 @@ namespace SourceGit.ViewModels foreach (var f in founded) { - var parent = new DirectoryInfo(f).Parent!.FullName.Replace("\\", "/"); + var parent = new DirectoryInfo(f.Path).Parent!.FullName.Replace("\\", "/"); if (parent.Equals(normalizedRoot, StringComparison.Ordinal)) { - Preferences.Instance.FindOrAddNodeByRepositoryPath(f, null, false); + Preferences.Instance.FindOrAddNodeByRepositoryPath(f.Path, null, false); } else if (parent.StartsWith(normalizedRoot, StringComparison.Ordinal)) { var relative = parent.Substring(normalizedRoot.Length).TrimStart('/'); var group = FindOrCreateGroupRecursive(Preferences.Instance.RepositoryNodes, relative); - Preferences.Instance.FindOrAddNodeByRepositoryPath(f, group, false); + Preferences.Instance.FindOrAddNodeByRepositoryPath(f.Path, group, false); } } @@ -85,7 +85,7 @@ namespace SourceGit.ViewModels } } - private void GetUnmanagedRepositories(DirectoryInfo dir, List outs, EnumerationOptions opts, int depth = 0) + private void GetUnmanagedRepositories(DirectoryInfo dir, List outs, EnumerationOptions opts, int depth = 0) { var subdirs = dir.GetDirectories("*", opts); foreach (var subdir in subdirs) @@ -111,12 +111,19 @@ namespace SourceGit.ViewModels { var normalized = test.StdOut.Trim().Replace("\\", "/"); if (!_managed.Contains(normalized)) - outs.Add(normalized); + outs.Add(new FoundRepository(normalized, false)); } continue; } + var isBare = new Commands.IsBareRepository(subdir.FullName).Result(); + if (isBare) + { + outs.Add(new FoundRepository(normalizedSelf, true)); + continue; + } + if (depth < 5) GetUnmanagedRepositories(subdir, outs, opts, depth + 1); } @@ -161,6 +168,12 @@ namespace SourceGit.ViewModels return added; } + private record FoundRepository(string path, bool isBare) + { + public string Path { get; set; } = path; + public bool IsBare { get; set; } = isBare; + } + private HashSet _managed = new HashSet(); } } diff --git a/src/ViewModels/Welcome.cs b/src/ViewModels/Welcome.cs index 5c9c9380..95f7f010 100644 --- a/src/ViewModels/Welcome.cs +++ b/src/ViewModels/Welcome.cs @@ -94,20 +94,20 @@ namespace SourceGit.ViewModels } var isBare = new Commands.IsBareRepository(path).Result(); - if (isBare) + var repoRoot = path; + if (!isBare) { - App.RaiseException(string.Empty, $"'{path}' is a bare repository, which is not supported by SourceGit!"); - return; + var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd(); + if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut)) + { + InitRepository(path, parent, test.StdErr); + return; + } + + repoRoot = test.StdOut.Trim(); } - var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd(); - if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut)) - { - InitRepository(path, parent, test.StdErr); - return; - } - - var node = Preferences.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), parent, bMoveExistedNode); + var node = Preferences.Instance.FindOrAddNodeByRepositoryPath(repoRoot, parent, bMoveExistedNode); Refresh(); var launcher = App.GetLauncer(); diff --git a/src/Views/CreateBranch.axaml b/src/Views/CreateBranch.axaml index 43f4e50c..d8b89eb4 100644 --- a/src/Views/CreateBranch.axaml +++ b/src/Views/CreateBranch.axaml @@ -18,8 +18,8 @@ - - + + - - - - - + Text="{DynamicResource Text.CreateBranch.LocalChanges}" + IsVisible="{Binding !IsBareRepository}"/> + + + + + + + + IsChecked="{Binding CheckoutAfterCreated, Mode=TwoWay}" + IsVisible="{Binding !IsBareRepository}"/> From a112d212dc75977af74118b86240a88f92afa8f3 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 13 Jan 2025 20:41:03 +0800 Subject: [PATCH 13/25] enhance: disable pull/stash/apply/git-flow/git-lfs buttons in `bare` repository --- src/Views/CreateBranch.axaml | 2 +- src/Views/RepositoryToolbar.axaml | 10 +++++----- src/Views/RepositoryToolbar.axaml.cs | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Views/CreateBranch.axaml b/src/Views/CreateBranch.axaml index d8b89eb4..49bfda8d 100644 --- a/src/Views/CreateBranch.axaml +++ b/src/Views/CreateBranch.axaml @@ -70,7 +70,7 @@ Text="{DynamicResource Text.CreateBranch.LocalChanges}" IsVisible="{Binding !IsBareRepository}"/> - + - - - @@ -88,11 +88,11 @@ - - diff --git a/src/Views/RepositoryToolbar.axaml.cs b/src/Views/RepositoryToolbar.axaml.cs index aa78c4d3..66b49fc2 100644 --- a/src/Views/RepositoryToolbar.axaml.cs +++ b/src/Views/RepositoryToolbar.axaml.cs @@ -59,6 +59,12 @@ namespace SourceGit.Views var launcher = this.FindAncestorOfType(); if (launcher is not null && DataContext is ViewModels.Repository repo) { + if (repo.IsBare) + { + App.RaiseException(repo.FullPath, "Can't run `git pull` in bare repository!"); + return; + } + var startDirectly = launcher.HasKeyModifier(KeyModifiers.Control); launcher.ClearKeyModifier(); repo.Pull(startDirectly); From 5acc6e69287c0861755b74a7b028c6f1802297e1 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 13 Jan 2025 20:46:39 +0800 Subject: [PATCH 14/25] enhance: double-click commit in histories of a bare repository --- src/ViewModels/Histories.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index b890b76e..ec880b24 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -213,7 +213,7 @@ namespace SourceGit.ViewModels { if (firstRemoteBranch != null) _repo.ShowPopup(new CreateBranch(_repo, firstRemoteBranch)); - else + else if (!_repo.IsBare) _repo.ShowPopup(new CheckoutCommit(_repo, commit)); } } From a9327274c6ba847545d969dbf8758e5937e26858 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 14 Jan 2025 17:25:18 +0800 Subject: [PATCH 15/25] enhance: disable `LOCAL CHANGES` and `STASHES` for bare repository (#899) --- src/Views/Repository.axaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index d935d754..00f9f6ce 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -40,7 +40,7 @@ - +