From be8a38cb7e74a201801471ed919382df4c0bd4d5 Mon Sep 17 00:00:00 2001
From: JC-Chung <52159296+JC-Chung@users.noreply.github.com>
Date: Wed, 15 Jul 2026 19:55:06 +0800
Subject: [PATCH] feat: add "fetch all repositories" action in workspace menu
---
src/Resources/Locales/en_US.axaml | 1 +
src/Resources/Locales/zh_CN.axaml | 1 +
src/Resources/Locales/zh_TW.axaml | 1 +
src/ViewModels/Launcher.cs | 22 ++++++++++++++++++++
src/ViewModels/Repository.cs | 34 +++++++++++++++++++++++++++++++
src/Views/Launcher.axaml.cs | 14 +++++++++++++
6 files changed, 73 insertions(+)
diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index 4e49e74ed..6172944e9 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -1025,6 +1025,7 @@
Template: ${0}$
WORKSPACE:
Configure Workspaces...
+ Fetch All Repositories
WORKTREE
BRANCH
Copy Path
diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml
index 2718abe21..153292490 100644
--- a/src/Resources/Locales/zh_CN.axaml
+++ b/src/Resources/Locales/zh_CN.axaml
@@ -1029,6 +1029,7 @@
模板:${0}$
工作区:
配置工作区...
+ 拉取工作区所有仓库
本地工作树
連結分支
复制工作树路径
diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml
index f86247435..9af1151d4 100644
--- a/src/Resources/Locales/zh_TW.axaml
+++ b/src/Resources/Locales/zh_TW.axaml
@@ -1029,6 +1029,7 @@
範本: ${0}$
工作區:
設定工作區...
+ 提取工作區所有存放庫
本機工作區
分支
複製工作區路徑
diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs
index 7b17290a7..b283db913 100644
--- a/src/ViewModels/Launcher.cs
+++ b/src/ViewModels/Launcher.cs
@@ -1,6 +1,8 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Text;
+using System.Threading.Tasks;
using Avalonia.Collections;
using Avalonia.Threading;
@@ -122,6 +124,26 @@ public void CloseAll()
_ignoreIndexChange = false;
}
+ public async Task FetchAllRepositoriesAsync()
+ {
+ // avoid collection was modified while enumerating.
+ var pages = new List();
+ pages.AddRange(Pages);
+
+ var count = 0;
+ foreach (var page in pages)
+ {
+ if (page.Data is Repository repo)
+ {
+ if (await repo.FetchAllRemotesAsync())
+ count++;
+ }
+ }
+
+ if (count > 0)
+ Models.Notification.Send(null, $"Fetched {count} repositories");
+ }
+
public void SwitchWorkspace(Workspace to)
{
if (to == null || to.IsActive)
diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs
index 99a3a47e2..5894148f9 100644
--- a/src/ViewModels/Repository.cs
+++ b/src/ViewModels/Repository.cs
@@ -688,6 +688,40 @@ public async Task FetchAsync(bool autoStart)
ShowPopup(new Fetch(this));
}
+ public async Task FetchAllRemotesAsync()
+ {
+ if (IsAutoFetching)
+ return false;
+
+ CommandLog log = null;
+
+ try
+ {
+ var lockFile = Path.Combine(GitDir, "index.lock");
+ if (File.Exists(lockFile))
+ return false;
+
+ if (_remotes.Count == 0)
+ return false;
+
+ IsAutoFetching = true;
+ log = CreateLog("Fetch");
+
+ foreach (var remote in _remotes)
+ await new Commands.Fetch(FullPath, remote.Name).Use(log).RunAsync();
+
+ _lastFetchTime = DateTime.Now;
+ }
+ catch
+ {
+ // Ignore all exceptions.
+ }
+
+ IsAutoFetching = false;
+ log?.Complete();
+ return true;
+ }
+
public async Task PullAsync(bool autoStart)
{
if (IsBare || !CanCreatePopup())
diff --git a/src/Views/Launcher.axaml.cs b/src/Views/Launcher.axaml.cs
index 99ebf66d9..4fc49788e 100644
--- a/src/Views/Launcher.axaml.cs
+++ b/src/Views/Launcher.axaml.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using Avalonia;
using Avalonia.Controls;
@@ -395,6 +396,19 @@ private void OnOpenWorkspaceMenu(object sender, RoutedEventArgs e)
menu.Items.Add(new MenuItem() { Header = "-" });
+ var hasRepos = launcher.Pages.Any(p => p.Data is ViewModels.Repository);
+
+ var fetchAll = new MenuItem();
+ fetchAll.Header = App.Text("Workspace.FetchAllRepositories");
+ fetchAll.Icon = this.CreateMenuIcon("Icons.Fetch");
+ fetchAll.IsEnabled = hasRepos;
+ fetchAll.Click += async (_, ev) =>
+ {
+ await launcher.FetchAllRepositoriesAsync();
+ ev.Handled = true;
+ };
+ menu.Items.Add(fetchAll);
+
var configure = new MenuItem();
configure.Header = App.Text("Workspace.Configure");
configure.Click += async (_, ev) =>