From 37ec68969a53808eaab6a78500ecf076e3ab0d4b Mon Sep 17 00:00:00 2001 From: Andrea Corti Date: Fri, 20 Nov 2026 09:01:56 +0100 Subject: [PATCH 1/2] Changed the "search repositories" behaviour Now we can also open a folder or a remote repository directly from search --- src/Resources/Locales/ca_ES.axaml | 2 +- src/Resources/Locales/de_DE.axaml | 2 +- src/Resources/Locales/el_GR.axaml | 2 +- src/Resources/Locales/en_US.axaml | 2 +- src/Resources/Locales/es_ES.axaml | 2 +- src/Resources/Locales/fr_FR.axaml | 2 +- src/Resources/Locales/he_IL.axaml | 2 +- src/Resources/Locales/id_ID.axaml | 2 +- src/Resources/Locales/it_IT.axaml | 2 +- src/Resources/Locales/ja_JP.axaml | 2 +- src/Resources/Locales/ko_KR.axaml | 2 +- src/Resources/Locales/pt_BR.axaml | 2 +- src/Resources/Locales/ru_RU.axaml | 2 +- src/Resources/Locales/ta_IN.axaml | 2 +- src/Resources/Locales/uk_UA.axaml | 2 +- src/Resources/Locales/zh_CN.axaml | 2 +- src/Resources/Locales/zh_TW.axaml | 2 +- src/ViewModels/Welcome.cs | 66 +++++++++++++++++++++++++++++++ src/Views/Clone.axaml.cs | 4 +- src/Views/Welcome.axaml | 1 + src/Views/Welcome.axaml.cs | 28 +++++++++++++ 21 files changed, 114 insertions(+), 19 deletions(-) diff --git a/src/Resources/Locales/ca_ES.axaml b/src/Resources/Locales/ca_ES.axaml index a37a7709db..3d397c3459 100644 --- a/src/Resources/Locales/ca_ES.axaml +++ b/src/Resources/Locales/ca_ES.axaml @@ -1034,7 +1034,7 @@ Obre el repositori Obre el terminal Torna a escanejar els repositoris al directori de clonació per defecte - Cerca repositoris... + Cerca, carrega o obre repositoris Canvis locals Git Ignore Ignora tots els fitxers *{0} diff --git a/src/Resources/Locales/de_DE.axaml b/src/Resources/Locales/de_DE.axaml index 9c59fd3deb..d63d7ba37b 100644 --- a/src/Resources/Locales/de_DE.axaml +++ b/src/Resources/Locales/de_DE.axaml @@ -971,7 +971,7 @@ $1, $2, … Werte der Eingabe-Steuerelemente Öffne Repository Öffne Terminal Standard Klon-Ordner erneut nach Repositorys durchsuchen - Suche Repositorys… + Repositorys suchen, laden oder öffnen ÄNDERUNGEN Git Ignore Ignoriere alle *{0} Dateien diff --git a/src/Resources/Locales/el_GR.axaml b/src/Resources/Locales/el_GR.axaml index 22cb8b4c74..90e24e2630 100644 --- a/src/Resources/Locales/el_GR.axaml +++ b/src/Resources/Locales/el_GR.axaml @@ -967,7 +967,7 @@ Άνοιγμα αποθετηρίου Άνοιγμα τερματικού Επανασάρωση αποθετηρίων στον προεπιλεγμένο φάκελο κλωνοποίησης - Αναζήτηση αποθετηρίων... + Αναζήτηση, φόρτωση ή άνοιγμα αποθετηρίων ΤΟΠΙΚΕΣ ΑΛΛΑΓΕΣ Git Ignore Αγνόηση όλων των αρχείων *{0} diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 8a4899b655..a91d42a227 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -1047,7 +1047,7 @@ Manually add a branch/tag history filter will disable this feature automatically Open Terminal Refresh Status Rescan Repositories in Default Clone Dir - Search Repositories... + Search, load or open repositories Check repository status when opening the Welcome page Local Changes Git Ignore diff --git a/src/Resources/Locales/es_ES.axaml b/src/Resources/Locales/es_ES.axaml index 37acc15270..8ea33c42c7 100644 --- a/src/Resources/Locales/es_ES.axaml +++ b/src/Resources/Locales/es_ES.axaml @@ -1049,7 +1049,7 @@ Agregar manualmente un filtro del historial a una rama/etiqueta desactivará est Abrir Repositorio Abrir Terminal Reescanear Repositorios en el Directorio de Clonado por Defecto - Buscar Repositorios... + Buscar, cargar o abrir repositorios Cambios Git Ignore Ignorar todos los archivos *{0} diff --git a/src/Resources/Locales/fr_FR.axaml b/src/Resources/Locales/fr_FR.axaml index 6b7bacef1c..8f3ed86046 100644 --- a/src/Resources/Locales/fr_FR.axaml +++ b/src/Resources/Locales/fr_FR.axaml @@ -928,7 +928,7 @@ Ouvrir un dépôt Ouvrir le terminal Réanalyser les repositories dans le dossier de clonage par défaut - Chercher des dépôts... + Rechercher, charger ou ouvrir des dépôts Changements Git Ignore Ignorer tous les *{0} fichiers diff --git a/src/Resources/Locales/he_IL.axaml b/src/Resources/Locales/he_IL.axaml index 153f55ef78..fd3a9210e4 100644 --- a/src/Resources/Locales/he_IL.axaml +++ b/src/Resources/Locales/he_IL.axaml @@ -928,7 +928,7 @@ פתח מאגר פתח טרמינל סרוק מחדש של מאגרים בתיקיית ה־Clone ברירת מחדל - חיפוש מאגרים... + חיפוש, טעינה או פתיחה של מאגרים שינויים מקומיים Git Ignore התעלמות מכל הקבצים *{0} diff --git a/src/Resources/Locales/id_ID.axaml b/src/Resources/Locales/id_ID.axaml index d8eda31ee4..12b18b0407 100644 --- a/src/Resources/Locales/id_ID.axaml +++ b/src/Resources/Locales/id_ID.axaml @@ -972,7 +972,7 @@ Buka Repositori Buka Terminal Pindai Ulang Repositori di Direktori Clone Default - Cari Repositori... + Cari, muat atau buka repositori PERUBAHAN LOKAL Git Ignore Abaikan semua berkas *{0} diff --git a/src/Resources/Locales/it_IT.axaml b/src/Resources/Locales/it_IT.axaml index eee191cedc..a2f6786036 100644 --- a/src/Resources/Locales/it_IT.axaml +++ b/src/Resources/Locales/it_IT.axaml @@ -867,7 +867,7 @@ ${pure_files:N} Come ${files:N}, ma senza cartelle Apri Repository Apri Terminale Riscansiona Repository nella Cartella Clone Predefinita - Cerca Repository... + Cerca, carica o apri repository MODIFICHE LOCALI Git Ignore Ignora tutti i file *{0} diff --git a/src/Resources/Locales/ja_JP.axaml b/src/Resources/Locales/ja_JP.axaml index fdef11c278..9f8363af53 100644 --- a/src/Resources/Locales/ja_JP.axaml +++ b/src/Resources/Locales/ja_JP.axaml @@ -1013,7 +1013,7 @@ リポジトリを開く 端末を開く 既定のクローンディレクトリ内のリポジトリを再スキャン - リポジトリを検索... + リポジトリを検索、読み込み、または開く ローカルの変更 無視 *{0} ファイルをすべて無視 diff --git a/src/Resources/Locales/ko_KR.axaml b/src/Resources/Locales/ko_KR.axaml index e3dda7a432..238d1d0fb5 100644 --- a/src/Resources/Locales/ko_KR.axaml +++ b/src/Resources/Locales/ko_KR.axaml @@ -936,7 +936,7 @@ 저장소 열기 터미널 열기 기본 복제 디렉터리의 저장소 다시 스캔 - 저장소 검색... + 저장소 검색, 불러오기 또는 열기 로컬 변경 사항 Git 무시 모든 *{0} 파일 무시 diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml index 5084f0180b..dbddc641ee 100644 --- a/src/Resources/Locales/pt_BR.axaml +++ b/src/Resources/Locales/pt_BR.axaml @@ -603,7 +603,7 @@ Abrir Repositório Abrir Terminal Reescanear Repositórios no Diretório de Clone Padrão - Buscar Repositórios... + Buscar, carregar ou abrir repositórios Alterações Git Ignore Ignorar todos os arquivos *{0} diff --git a/src/Resources/Locales/ru_RU.axaml b/src/Resources/Locales/ru_RU.axaml index 9353c001bb..9e169cc0bd 100644 --- a/src/Resources/Locales/ru_RU.axaml +++ b/src/Resources/Locales/ru_RU.axaml @@ -1049,7 +1049,7 @@ Открыть репозиторий Открыть терминал Обнаружить репозитории в каталоге клонирования по умолчанию - Найти репозиторий... + Найти, загрузить или открыть репозитории Изменения Игнорировать Git Игнорировать все *{0} файлы diff --git a/src/Resources/Locales/ta_IN.axaml b/src/Resources/Locales/ta_IN.axaml index 3473ff1cab..d072152d7c 100644 --- a/src/Resources/Locales/ta_IN.axaml +++ b/src/Resources/Locales/ta_IN.axaml @@ -617,7 +617,7 @@ களஞ்சியத்தைத் திற முனையத்தைத் திற இயல்புநிலை நகலி அடைவில் களஞ்சியங்களை மீண்டும் வருடு - களஞ்சியங்களைத் தேடு... + களஞ்சியங்களைத் தேடு, ஏற்று அல்லது திற உள்ளக மாற்றங்கள் அறிவிலி புறக்கணி எல்லா *{0} கோப்புகளையும் புறக்கணி diff --git a/src/Resources/Locales/uk_UA.axaml b/src/Resources/Locales/uk_UA.axaml index 5f44193e39..8e42462218 100644 --- a/src/Resources/Locales/uk_UA.axaml +++ b/src/Resources/Locales/uk_UA.axaml @@ -622,7 +622,7 @@ Відкрити сховище Відкрити термінал Пересканувати сховища у теці клонування за замовчуванням - Пошук сховищ... + Знайти, завантажити або відкрити сховища ЛОКАЛЬНІ ЗМІНИ Git Ignore Ігнорувати всі файли *{0} diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index c77a185425..a98baab620 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -1051,7 +1051,7 @@ 打开终端 刷新状态 重新扫描默认克隆路径下的仓库 - 快速查找仓库... + 搜索、加载或打开仓库 打开起始页时检查仓库状态 本地更改 添加至 .gitignore 忽略列表 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index c9089258d9..b3db063171 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -1036,7 +1036,7 @@ 開啟終端機 重新整理狀態 重新掃描預設複製 (clone) 目錄下的存放庫 - 篩選存放庫... + 搜尋、載入或開啟存放庫 開啟起始頁時檢查存放庫狀態 本機變更 加入至 .gitignore 忽略清單 diff --git a/src/ViewModels/Welcome.cs b/src/ViewModels/Welcome.cs index 75c853b44a..2d8bd4d974 100644 --- a/src/ViewModels/Welcome.cs +++ b/src/ViewModels/Welcome.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.IO; using System.Threading; using System.Threading.Tasks; @@ -164,6 +165,71 @@ public void Clone() activePage.Popup = new Clone(activePage.Node.Id); } + public async Task TryOpenSearchAsync(LauncherPage page, CancellationToken token) + { + var filter = SearchFilter; + var input = filter?.Trim() ?? string.Empty; + if (input.Length > 1 && input[0] == '"' && input[^1] == '"') + input = input[1..^1]; + + var isLocal = Directory.Exists(input); + var isRemote = Models.Remote.IsSSH(input) || + (Uri.TryCreate(input, UriKind.Absolute, out var uri) && + (uri.Scheme == Uri.UriSchemeHttps || uri.Scheme == Uri.UriSchemeHttp) && + Models.Remote.IsValidURL(input)); + if (!isLocal && !isRemote) + return false; + + if (page == null || page.Popup != null || token.IsCancellationRequested) + return true; + + if (!Preferences.Instance.IsGitConfigured()) + { + Models.Notification.Send(page.Node.Id, App.Text("NotConfigured"), true); + return true; + } + + if (isLocal) + { + var result = await GetRepositoryRootAsync(input); + if (token.IsCancellationRequested || SearchFilter != filter || + App.GetLauncher().ActivePage != page || page.Popup != null) + return true; + + if (!result.IsSuccess && !Models.SafeDirectories.IsUntrustedRepository(result.StdErr)) + { + Models.Notification.Send(page.Node.Id, result.StdErr, true); + return true; + } + + page.Popup = new OpenLocalRepository(page.Node.Id, null) { RepoPath = input }; + await page.ProcessPopupAsync(); + } + else + { + using var cancellation = CancellationTokenSource.CreateLinkedTokenSource(token); + cancellation.CancelAfter(TimeSpan.FromSeconds(30)); + var command = new Commands.Command + { + Context = page.Node.Id, + Args = $"ls-remote -- {input.Quoted()} HEAD", + CancellationToken = cancellation.Token, + }; + var valid = await command.ExecAsync(); + if (cancellation.IsCancellationRequested) + { + if (!token.IsCancellationRequested) + Models.Notification.Send(page.Node.Id, "Timed out checking the remote repository.", true); + return true; + } + + if (valid && SearchFilter == filter && App.GetLauncher().ActivePage == page && page.Popup == null) + page.Popup = new Clone(page.Node.Id) { Remote = input }; + } + + return true; + } + public void OpenLocalRepository() { if (!Preferences.Instance.IsGitConfigured()) diff --git a/src/Views/Clone.axaml.cs b/src/Views/Clone.axaml.cs index f7791161c3..81d3147a1a 100644 --- a/src/Views/Clone.axaml.cs +++ b/src/Views/Clone.axaml.cs @@ -19,7 +19,7 @@ protected override async void OnLoaded(RoutedEventArgs e) { base.OnLoaded(e); - if (DataContext is not ViewModels.Clone vm) + if (DataContext is not ViewModels.Clone vm || !string.IsNullOrEmpty(vm.Remote)) return; var clipboard = TopLevel.GetTopLevel(this)?.Clipboard; @@ -28,7 +28,7 @@ protected override async void OnLoaded(RoutedEventArgs e) try { var text = await clipboard.TryGetTextAsync(); - if (Models.Remote.IsValidURL(text)) + if (string.IsNullOrEmpty(vm.Remote) && Models.Remote.IsValidURL(text)) vm.Remote = text; } catch diff --git a/src/Views/Welcome.axaml b/src/Views/Welcome.axaml index 8f21e33dc3..c5dd2ba526 100644 --- a/src/Views/Welcome.axaml +++ b/src/Views/Welcome.axaml @@ -29,6 +29,7 @@ Background="{DynamicResource Brush.Contents}" Watermark="{DynamicResource Text.Welcome.Search}" VerticalContentAlignment="Center" + KeyDown="OnSearchBoxKeyDown" Text="{Binding SearchFilter, Mode=TwoWay}">