GitHub improvements

This commit is contained in:
Andy Dixon
2026-04-20 13:40:00 +01:00
parent 1d97e907e0
commit c5debd9c77
20 changed files with 2525 additions and 1238 deletions
+41
View File
@@ -10,6 +10,7 @@ import (
"net"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
@@ -748,6 +749,46 @@ func (s *Service) RefreshGitHubRepos(sessionID string) ([]models.GitHubRepo, err
return s.sessions.FetchGitHubRepos(sessionID)
}
// DownloadGitHubRepoArchive downloads a repository zip archive to a local file.
func (s *Service) DownloadGitHubRepoArchive(sessionID string, fullName string, ref string) (string, error) {
if s.ctx == nil {
return "", fmt.Errorf("application context not set")
}
if fullName == "" {
return "", fmt.Errorf("repository name cannot be empty")
}
parts := strings.Split(fullName, "/")
repoName := parts[len(parts)-1]
defaultName := repoName + ".zip"
if ref != "" {
safeRef := strings.ReplaceAll(ref, "/", "-")
defaultName = fmt.Sprintf("%s-%s.zip", repoName, safeRef)
}
path, err := wailsRuntime.SaveFileDialog(s.ctx, wailsRuntime.SaveDialogOptions{
Title: "Download Repository",
DefaultFilename: defaultName,
Filters: []wailsRuntime.FileFilter{
{DisplayName: "Zip Archive (*.zip)", Pattern: "*.zip"},
},
})
if err != nil {
return "", fmt.Errorf("save dialog failed: %w", err)
}
if path == "" {
return "", fmt.Errorf("download cancelled")
}
if filepath.Ext(path) != ".zip" {
path += ".zip"
}
if err := s.sessions.DownloadGitHubArchive(sessionID, fullName, ref, path); err != nil {
return "", err
}
return path, nil
}
// ---------------------------------------------------------------------------
// Port forwarding
// ---------------------------------------------------------------------------