Files
Gitpub-Desktop/frontend/js/tauri-api.js
T
andrew 346f8536f0 Add local repository scanning and UI
Implement local repository scanning end-to-end. Frontend: add UI (toolbar, local-scan panel, list/cards), CSS styles, icons, new state fields, and templates; convert recent repo items to buttons and wire up actions to select, view and open scanned repos. JS: add helper utilities (repoNameFromPath, normalizeRemoteUrl, serverRepoRemoteUrls), scanForLocalRepos/selectLocalRepo functions, render template for scan results, and call scanLocalRepos via tauri-api. Tauri API: expose scan_local_repos (tauri command) in tauri-api.js. Backend (Rust): add LocalRepoCandidate type and a scanner implementation that walks configurable/default roots, deduplicates paths, matches local remotes against allowed server URLs, enforces depth/result limits, and returns matched candidates; register scan_local_repos in the command list. Includes error handling and user-facing messages for missing roots or remotes.
2026-05-10 14:32:41 +12:00

78 lines
1.9 KiB
JavaScript

const invoke = window.__TAURI__?.core?.invoke;
function ensureInvoke() {
if (!invoke) {
throw new Error("Tauri invoke API is not available.");
}
}
export async function runGitClone(repoUrl, destinationPath, gitPath) {
ensureInvoke();
return invoke("git_clone", {
repoUrl,
destinationPath,
gitPath: gitPath || null,
});
}
export async function runGitPull(repoPath, gitPath) {
ensureInvoke();
return invoke("git_pull", { repoPath, gitPath: gitPath || null });
}
export async function runGitPush(repoPath, gitPath) {
ensureInvoke();
return invoke("git_push", { repoPath, gitPath: gitPath || null });
}
export async function runGitStatus(repoPath, gitPath) {
ensureInvoke();
return invoke("git_status", { repoPath, gitPath: gitPath || null });
}
export async function runGitBranch(repoPath, gitPath) {
ensureInvoke();
return invoke("git_branch", { repoPath, gitPath: gitPath || null });
}
export async function scanLocalRepos(roots = [], allowedRemoteUrls = [], gitPath = "", maxDepth = 4, maxResults = 200) {
ensureInvoke();
return invoke("scan_local_repos", {
roots,
allowedRemoteUrls,
gitPath: gitPath || null,
maxDepth,
maxResults,
});
}
export async function listLocalRepoBranches(repoPath, gitPath) {
ensureInvoke();
return invoke("local_repo_branches", { repoPath, gitPath: gitPath || null });
}
export async function listLocalRepoTree(repoPath, reference, path, gitPath) {
ensureInvoke();
return invoke("local_repo_tree", {
repoPath,
reference,
path: path || "",
gitPath: gitPath || null,
});
}
export async function readLocalRepoFile(repoPath, reference, path, gitPath) {
ensureInvoke();
return invoke("local_repo_file", {
repoPath,
reference,
path,
gitPath: gitPath || null,
});
}
export async function testGiteaConnection(payload) {
ensureInvoke();
return invoke("test_gitea_connection", payload);
}