Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f0904e839 | ||
|
|
e3df75cc38 | ||
|
|
794680a696 | ||
|
|
18476d9d92 | ||
|
|
3a8c114d82 | ||
|
|
0edf2819dc | ||
|
|
5d34147b41 | ||
|
|
e18f8f1040 | ||
|
|
310a0fb09a | ||
|
|
b04158926d | ||
|
|
eef4869bbb | ||
|
|
97fc4fc1e0 | ||
|
|
e6d22765be |
@@ -28,7 +28,13 @@
|
||||
"Bash(xxd)",
|
||||
"Bash(python3 -)",
|
||||
"Bash(echo \"exit: $?\")",
|
||||
"Bash(grep -n \"input,\\\\|select,\\\\|input {\\\\|select {\\\\|.repo-form input\\\\|input:focus\\\\|::placeholder\" src/app.css)"
|
||||
"Bash(grep -n \"input,\\\\|select,\\\\|input {\\\\|select {\\\\|.repo-form input\\\\|input:focus\\\\|::placeholder\" src/app.css)",
|
||||
"Bash(sudo -n true)",
|
||||
"Bash(rustc --version)",
|
||||
"Read(//mnt/c/Users/cbr/Desktop/src-tauri/src/**)",
|
||||
"Bash(sudo apt install -y libdbus-1-dev pkg-config)",
|
||||
"Bash(dpkg -l)",
|
||||
"Bash(apt list *)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,3 +5,4 @@
|
||||
.idea
|
||||
.DS_Store
|
||||
~
|
||||
.codex*
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "tauri-git-lite",
|
||||
"version": "2026.7.1",
|
||||
"version": "2026.7.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "tauri-git-lite",
|
||||
"version": "2026.7.1",
|
||||
"version": "2026.7.5",
|
||||
"dependencies": {
|
||||
"@lucide/svelte": "^1.21.0",
|
||||
"@tailwindcss/vite": "^4.3.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "git-lite",
|
||||
"version": "2026.7.1",
|
||||
"version": "2026.7.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
Generated
+13
-13
@@ -1392,6 +1392,19 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "git_lite"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"keyring",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-dialog",
|
||||
"tauri-plugin-updater",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.18.5"
|
||||
@@ -4121,19 +4134,6 @@ dependencies = [
|
||||
"toml 1.1.2+spec-1.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri_git_lite"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"keyring",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-dialog",
|
||||
"tauri-plugin-updater",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.27.0"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "tauri_git_lite"
|
||||
name = "git_lite"
|
||||
version = "0.1.0"
|
||||
description = "Rust backend for a lightweight Git desktop client"
|
||||
edition = "2021"
|
||||
|
||||
+538
-31
@@ -208,6 +208,28 @@ pub fn open_repository(path: String) -> Result<GitStatus, String> {
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn open_repo_in_explorer(path: String) -> Result<(), String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
open_path_in_file_manager(&repo)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn open_repository_file(path: String, file: String) -> Result<(), String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
validate_files(std::slice::from_ref(&file))?;
|
||||
let file_path = resolve_repo_child_path(&repo, &file)?;
|
||||
|
||||
if !file_path.exists() {
|
||||
return Err(format!("Datei '{file}' existiert im Working Tree nicht."));
|
||||
}
|
||||
if !file_path.is_file() {
|
||||
return Err(format!("'{file}' ist keine Datei."));
|
||||
}
|
||||
|
||||
reveal_path_in_file_manager(&file_path)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct RepositoryBundle {
|
||||
pub status: GitStatus,
|
||||
@@ -341,13 +363,65 @@ pub fn create_branch(
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn rename_branch(
|
||||
path: String,
|
||||
old_branch: String,
|
||||
new_branch: String,
|
||||
) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let old_branch = validate_existing_local_branch_name(&repo, &old_branch)?;
|
||||
let new_branch = validate_new_branch_name(&repo, &new_branch)?;
|
||||
|
||||
run_git(
|
||||
&repo,
|
||||
[
|
||||
"branch",
|
||||
"-m",
|
||||
"--",
|
||||
old_branch.as_str(),
|
||||
new_branch.as_str(),
|
||||
],
|
||||
)?;
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn delete_branch(path: String, branch: String) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let branch = validate_existing_local_branch_name(&repo, &branch)?;
|
||||
let status = status_for_repo(&repo)?;
|
||||
if status.current_branch.as_deref() == Some(branch.as_str()) {
|
||||
return Err("Der aktuelle Branch kann nicht geloescht werden.".to_string());
|
||||
}
|
||||
|
||||
run_git(&repo, ["branch", "-d", "--", branch.as_str()])?;
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn stage_files(path: String, files: Vec<String>) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
validate_files(&files)?;
|
||||
|
||||
if !files.is_empty() {
|
||||
run_git_with_paths(&repo, &["add"], &files)?;
|
||||
// A file we've detected as an unstaged rename (see `detect_worktree_renames`) has
|
||||
// to be staged with both its old and new path so `git add` records it as a rename
|
||||
// instead of leaving the old path's deletion unstaged.
|
||||
let current_status = status_for_repo(&repo)?;
|
||||
let mut add_paths: Vec<String> = Vec::new();
|
||||
for file in &files {
|
||||
match find_status(¤t_status.files, file) {
|
||||
Some(entry) => {
|
||||
if let Some(old_path) = &entry.old_path {
|
||||
add_paths.push(old_path.clone());
|
||||
}
|
||||
add_paths.push(entry.path.clone());
|
||||
}
|
||||
None => add_paths.push(file.clone()),
|
||||
}
|
||||
}
|
||||
run_git_with_paths(&repo, &["add"], &add_paths)?;
|
||||
}
|
||||
|
||||
status_for_repo(&repo)
|
||||
@@ -728,15 +802,60 @@ pub fn list_repository_files(path: String) -> Result<Vec<GitRepositoryFile>, Str
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn list_file_history(
|
||||
pub async fn list_file_history(
|
||||
path: String,
|
||||
file: String,
|
||||
limit: Option<u32>,
|
||||
request_id: Option<String>,
|
||||
state: tauri::State<'_, SearchCancellationState>,
|
||||
) -> Result<Vec<GitCommit>, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let state = state.inner().clone();
|
||||
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let request_id = request_id
|
||||
.map(|id| id.trim().to_string())
|
||||
.filter(|id| !id.is_empty());
|
||||
let cancellation = request_id.as_ref().map(|request_id| SearchCancellation {
|
||||
state: state.clone(),
|
||||
search_id: request_id.clone(),
|
||||
});
|
||||
|
||||
let result = list_file_history_core(&repo, file, limit, cancellation.as_ref());
|
||||
|
||||
if let Some(request_id) = request_id.as_deref() {
|
||||
let _ = state.clear(request_id);
|
||||
}
|
||||
|
||||
result
|
||||
})
|
||||
.await
|
||||
.map_err(|err| format!("Dateihistorie konnte nicht geladen werden: {err}"))?
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn cancel_file_history(
|
||||
request_id: String,
|
||||
state: tauri::State<'_, SearchCancellationState>,
|
||||
) -> Result<(), String> {
|
||||
let request_id = request_id.trim();
|
||||
if request_id.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
state.cancel(request_id)
|
||||
}
|
||||
|
||||
fn list_file_history_core(
|
||||
repo: &Path,
|
||||
file: String,
|
||||
limit: Option<u32>,
|
||||
cancellation: Option<&SearchCancellation>,
|
||||
) -> Result<Vec<GitCommit>, String> {
|
||||
check_search_cancelled(cancellation)?;
|
||||
validate_files(std::slice::from_ref(&file))?;
|
||||
|
||||
if verify_commit(&repo, "HEAD").is_err() {
|
||||
if verify_commit(repo, "HEAD").is_err() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
@@ -748,13 +867,14 @@ pub fn list_file_history(
|
||||
OsString::from("-n"),
|
||||
OsString::from(limit),
|
||||
];
|
||||
if !is_repository_folder_path(&repo, &file)? {
|
||||
if !is_repository_folder_path(repo, &file)? {
|
||||
args.push(OsString::from("--follow"));
|
||||
}
|
||||
args.extend([OsString::from("--"), OsString::from(file)]);
|
||||
let output = run_git(&repo, args)?;
|
||||
let output = run_git_cancellable(repo, args, cancellation, "Git-Dateihistorie fehlgeschlagen")?;
|
||||
check_search_cancelled(cancellation)?;
|
||||
|
||||
parse_commit_log(&repo, &output)
|
||||
parse_commit_log(repo, &output)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -930,7 +1050,21 @@ pub fn restore_to_commit(path: String, commit: String) -> Result<GitStatus, Stri
|
||||
let repo = resolve_repo(&path)?;
|
||||
let commit_hash = verify_commit(&repo, &commit)?;
|
||||
|
||||
run_git(&repo, ["reset", "--hard", commit_hash.as_str()])?;
|
||||
// Non-destructive: bring the working tree back to how it looked at `commit` without
|
||||
// moving the branch pointer (unlike `git reset --hard`, which would rewrite history and
|
||||
// hide any newer commits from the log). The result lands as ordinary unstaged changes
|
||||
// that the user reviews in the status panel and stages/commits or discards explicitly.
|
||||
run_git(
|
||||
&repo,
|
||||
[
|
||||
"restore",
|
||||
"--source",
|
||||
commit_hash.as_str(),
|
||||
"--worktree",
|
||||
"--",
|
||||
".",
|
||||
],
|
||||
)?;
|
||||
status_for_repo(&repo)
|
||||
}
|
||||
|
||||
@@ -1314,6 +1448,99 @@ fn resolve_repo(path: &str) -> Result<PathBuf, String> {
|
||||
Ok(PathBuf::from(top_level))
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn open_path_in_file_manager(path: &Path) -> Result<(), String> {
|
||||
let native_path = path.to_string_lossy().replace('/', "\\");
|
||||
let mut command = Command::new("explorer.exe");
|
||||
command.arg(native_path);
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
command
|
||||
.spawn()
|
||||
.map_err(|err| format!("Explorer konnte nicht gestartet werden: {err}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn open_path_in_file_manager(path: &Path) -> Result<(), String> {
|
||||
Command::new("open")
|
||||
.arg(path)
|
||||
.spawn()
|
||||
.map_err(|err| format!("Finder konnte nicht gestartet werden: {err}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
fn open_path_in_file_manager(path: &Path) -> Result<(), String> {
|
||||
Command::new("xdg-open")
|
||||
.arg(path)
|
||||
.spawn()
|
||||
.map_err(|err| format!("Dateimanager konnte nicht gestartet werden: {err}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn resolve_repo_child_path(repo: &Path, child: &str) -> Result<PathBuf, String> {
|
||||
let child_path = Path::new(child);
|
||||
if child_path.is_absolute()
|
||||
|| child_path.components().any(|component| {
|
||||
matches!(
|
||||
component,
|
||||
std::path::Component::ParentDir
|
||||
| std::path::Component::RootDir
|
||||
| std::path::Component::Prefix(_)
|
||||
)
|
||||
})
|
||||
{
|
||||
return Err("Dateipfad muss innerhalb des Repositorys liegen.".to_string());
|
||||
}
|
||||
|
||||
let candidate = repo.join(child_path);
|
||||
let repo = repo
|
||||
.canonicalize()
|
||||
.map_err(|err| format!("Repository-Pfad konnte nicht aufgeloest werden: {err}"))?;
|
||||
let candidate = candidate
|
||||
.canonicalize()
|
||||
.map_err(|err| format!("Dateipfad konnte nicht aufgeloest werden: {err}"))?;
|
||||
|
||||
if !candidate.starts_with(&repo) {
|
||||
return Err("Dateipfad liegt ausserhalb des Repositorys.".to_string());
|
||||
}
|
||||
|
||||
Ok(candidate)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn reveal_path_in_file_manager(path: &Path) -> Result<(), String> {
|
||||
let native_path = path.to_string_lossy().replace('/', "\\");
|
||||
let mut command = Command::new("explorer.exe");
|
||||
command.arg(format!("/select,{native_path}"));
|
||||
command.creation_flags(CREATE_NO_WINDOW);
|
||||
command
|
||||
.spawn()
|
||||
.map_err(|err| format!("Explorer konnte nicht gestartet werden: {err}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn reveal_path_in_file_manager(path: &Path) -> Result<(), String> {
|
||||
Command::new("open")
|
||||
.arg("-R")
|
||||
.arg(path)
|
||||
.spawn()
|
||||
.map_err(|err| format!("Finder konnte nicht gestartet werden: {err}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
fn reveal_path_in_file_manager(path: &Path) -> Result<(), String> {
|
||||
// No universal "select this file" flag across Linux file managers; open its folder instead.
|
||||
let target = path.parent().unwrap_or(path);
|
||||
Command::new("xdg-open")
|
||||
.arg(target)
|
||||
.spawn()
|
||||
.map_err(|err| format!("Dateimanager konnte nicht gestartet werden: {err}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn verify_commit(repo: &Path, commit: &str) -> Result<String, String> {
|
||||
let commit = commit.trim();
|
||||
if commit.is_empty() {
|
||||
@@ -1343,7 +1570,8 @@ fn status_for_repo(repo: &Path) -> Result<GitStatus, String> {
|
||||
"--untracked-files=all",
|
||||
],
|
||||
)?;
|
||||
let (branch, files) = parse_status_output(&output)?;
|
||||
let (branch, mut files) = parse_status_output(&output)?;
|
||||
detect_worktree_renames(repo, &mut files);
|
||||
|
||||
Ok(GitStatus {
|
||||
repo_path: repo.to_string_lossy().to_string(),
|
||||
@@ -1356,6 +1584,125 @@ fn status_for_repo(repo: &Path) -> Result<GitStatus, String> {
|
||||
})
|
||||
}
|
||||
|
||||
// `git status` only auto-detects renames between HEAD and the index (staged changes).
|
||||
// A file renamed on disk but not yet `git add`ed shows up as a plain delete + untracked
|
||||
// pair instead. We detect that case ourselves by comparing content hashes: if an unstaged
|
||||
// deletion and an untracked file share the same blob hash (and the match is unambiguous),
|
||||
// we merge them into a single unstaged "renamed" entry, mirroring how git reports staged
|
||||
// renames. This is intentionally content-hash based (not similarity-based) so it never
|
||||
// mutates the repository's real index.
|
||||
const WORKTREE_RENAME_DETECTION_LIMIT: usize = 300;
|
||||
|
||||
fn detect_worktree_renames(repo: &Path, files: &mut Vec<GitFileStatus>) {
|
||||
let deleted_paths: Vec<String> = files
|
||||
.iter()
|
||||
.filter(|f| f.staged.is_none() && f.unstaged == Some(FileStatusKind::Deleted))
|
||||
.map(|f| f.path.clone())
|
||||
.collect();
|
||||
let untracked_paths: Vec<String> = files
|
||||
.iter()
|
||||
.filter(|f| f.staged.is_none() && f.unstaged == Some(FileStatusKind::Untracked))
|
||||
.map(|f| f.path.clone())
|
||||
.collect();
|
||||
|
||||
if deleted_paths.is_empty()
|
||||
|| untracked_paths.is_empty()
|
||||
|| deleted_paths.len() > WORKTREE_RENAME_DETECTION_LIMIT
|
||||
|| untracked_paths.len() > WORKTREE_RENAME_DETECTION_LIMIT
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let Ok(deleted_hashes) = index_blob_hashes(repo, &deleted_paths) else {
|
||||
return;
|
||||
};
|
||||
let Ok(untracked_hashes) = worktree_blob_hashes(repo, &untracked_paths) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let mut hash_to_deleted: BTreeMap<&str, Vec<&str>> = BTreeMap::new();
|
||||
for (path, hash) in &deleted_hashes {
|
||||
hash_to_deleted.entry(hash).or_default().push(path);
|
||||
}
|
||||
let mut hash_to_untracked: BTreeMap<&str, Vec<&str>> = BTreeMap::new();
|
||||
for (path, hash) in &untracked_hashes {
|
||||
hash_to_untracked.entry(hash).or_default().push(path);
|
||||
}
|
||||
|
||||
let mut renames: Vec<(String, String)> = Vec::new();
|
||||
for (hash, olds) in &hash_to_deleted {
|
||||
if olds.len() != 1 {
|
||||
continue;
|
||||
}
|
||||
if let Some(news) = hash_to_untracked.get(hash) {
|
||||
if news.len() == 1 {
|
||||
renames.push((olds[0].to_string(), news[0].to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (old_path, new_path) in renames {
|
||||
files.retain(|f| {
|
||||
!(f.path == old_path
|
||||
&& f.staged.is_none()
|
||||
&& f.unstaged == Some(FileStatusKind::Deleted))
|
||||
&& !(f.path == new_path
|
||||
&& f.staged.is_none()
|
||||
&& f.unstaged == Some(FileStatusKind::Untracked))
|
||||
});
|
||||
files.push(GitFileStatus {
|
||||
path: new_path,
|
||||
old_path: Some(old_path),
|
||||
staged: None,
|
||||
unstaged: Some(FileStatusKind::Renamed),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Batched via `git ls-files -s -z` (one process for every deleted path) rather than one
|
||||
// `git rev-parse` call per file, since this runs on every status refresh.
|
||||
fn index_blob_hashes(repo: &Path, paths: &[String]) -> Result<Vec<(String, String)>, String> {
|
||||
let mut args: Vec<OsString> = vec![
|
||||
OsString::from("ls-files"),
|
||||
OsString::from("-s"),
|
||||
OsString::from("-z"),
|
||||
OsString::from("--"),
|
||||
];
|
||||
args.extend(paths.iter().map(OsString::from));
|
||||
let output = run_git(repo, args)?;
|
||||
|
||||
let mut result = Vec::new();
|
||||
for entry in output.split(|byte| *byte == 0).filter(|e| !e.is_empty()) {
|
||||
let text = String::from_utf8_lossy(entry);
|
||||
let Some((meta, path)) = text.split_once('\t') else {
|
||||
continue;
|
||||
};
|
||||
let Some(hash) = meta.split_whitespace().nth(1) else {
|
||||
continue;
|
||||
};
|
||||
result.push((path.to_string(), hash.to_string()));
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
// Batched via `git hash-object --stdin-paths` (one process for every untracked path).
|
||||
fn worktree_blob_hashes(repo: &Path, paths: &[String]) -> Result<Vec<(String, String)>, String> {
|
||||
let stdin_data = paths.join("\n");
|
||||
let output = run_git_with_stdin(
|
||||
repo,
|
||||
["hash-object", "--stdin-paths"],
|
||||
stdin_data.as_bytes(),
|
||||
)?;
|
||||
|
||||
let hashes: Vec<String> = String::from_utf8_lossy(&output)
|
||||
.lines()
|
||||
.map(|line| line.trim().to_string())
|
||||
.filter(|line| !line.is_empty())
|
||||
.collect();
|
||||
|
||||
Ok(paths.iter().cloned().zip(hashes).collect())
|
||||
}
|
||||
|
||||
fn repository_files(repo: &Path) -> Result<Vec<GitRepositoryFile>, String> {
|
||||
let status = status_for_repo(repo)?;
|
||||
repository_files_with_status(repo, &status)
|
||||
@@ -2067,6 +2414,41 @@ fn validate_new_branch_name(repo: &Path, branch: &str) -> Result<String, String>
|
||||
Ok(normalized)
|
||||
}
|
||||
|
||||
fn validate_existing_local_branch_name(repo: &Path, branch: &str) -> Result<String, String> {
|
||||
let branch = branch.trim();
|
||||
if branch.is_empty() {
|
||||
return Err("Branch-Name darf nicht leer sein.".to_string());
|
||||
}
|
||||
|
||||
let normalized = validate_branch_ref_name(branch)?;
|
||||
if !ref_exists(repo, &format!("refs/heads/{normalized}"))? {
|
||||
return Err(format!(
|
||||
"Lokaler Branch '{normalized}' wurde nicht gefunden."
|
||||
));
|
||||
}
|
||||
|
||||
Ok(normalized)
|
||||
}
|
||||
|
||||
fn validate_branch_ref_name(branch: &str) -> Result<String, String> {
|
||||
let output = git_command()
|
||||
.args(["check-ref-format", "--branch", branch])
|
||||
.output()
|
||||
.map_err(|err| format!("Git konnte nicht gestartet werden. Ist Git installiert? {err}"))?;
|
||||
|
||||
if !output.status.success() {
|
||||
let details = command_output_details(&output);
|
||||
return Err(format!("Ungueltiger Branch-Name: {details}"));
|
||||
}
|
||||
|
||||
let normalized = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
Ok(if normalized.is_empty() {
|
||||
branch.to_string()
|
||||
} else {
|
||||
normalized
|
||||
})
|
||||
}
|
||||
|
||||
fn ref_exists(repo: &Path, ref_name: &str) -> Result<bool, String> {
|
||||
let output = git_command()
|
||||
.arg("-C")
|
||||
@@ -2100,13 +2482,22 @@ fn restore_worktree_files(
|
||||
|
||||
for file in files {
|
||||
let status = find_status(statuses, file);
|
||||
if matches!(
|
||||
status.and_then(|entry| entry.unstaged),
|
||||
Some(FileStatusKind::Untracked)
|
||||
) {
|
||||
clean_paths.push(file.clone());
|
||||
} else {
|
||||
restore_paths.push(file.clone());
|
||||
match status.and_then(|entry| entry.unstaged) {
|
||||
Some(FileStatusKind::Untracked) => clean_paths.push(file.clone()),
|
||||
// An unstaged rename (see `detect_worktree_renames`) has no index entry for the
|
||||
// new path, so `git restore` can't act on it directly: restore the original
|
||||
// content at the old path and drop the untracked new file instead.
|
||||
Some(FileStatusKind::Renamed) => {
|
||||
if let Some(entry) = status {
|
||||
if let Some(old_path) = entry.old_path.clone() {
|
||||
restore_paths.push(old_path);
|
||||
}
|
||||
clean_paths.push(entry.path.clone());
|
||||
} else {
|
||||
restore_paths.push(file.clone());
|
||||
}
|
||||
}
|
||||
_ => restore_paths.push(file.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2526,6 +2917,50 @@ where
|
||||
Err(format!("{context}: {details}"))
|
||||
}
|
||||
|
||||
fn run_git_with_stdin<I, S>(repo: &Path, args: I, stdin_data: &[u8]) -> Result<Vec<u8>, String>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
S: AsRef<OsStr>,
|
||||
{
|
||||
use std::io::Write;
|
||||
|
||||
let mut child = git_command()
|
||||
.arg("-C")
|
||||
.arg(repo)
|
||||
.args(args)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|err| format!("Git konnte nicht gestartet werden. Ist Git installiert? {err}"))?;
|
||||
|
||||
if let Some(mut stdin) = child.stdin.take() {
|
||||
stdin
|
||||
.write_all(stdin_data)
|
||||
.map_err(|err| format!("Eingabe konnte nicht an Git gesendet werden: {err}"))?;
|
||||
}
|
||||
|
||||
let output = child
|
||||
.wait_with_output()
|
||||
.map_err(|err| format!("Git-Ausgabe konnte nicht gelesen werden: {err}"))?;
|
||||
|
||||
if output.status.success() {
|
||||
return Ok(output.stdout);
|
||||
}
|
||||
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let details = if !stderr.trim().is_empty() {
|
||||
stderr.trim()
|
||||
} else if !stdout.trim().is_empty() {
|
||||
stdout.trim()
|
||||
} else {
|
||||
"unbekannter Fehler"
|
||||
};
|
||||
|
||||
Err(format!("Git-Befehl fehlgeschlagen: {details}"))
|
||||
}
|
||||
|
||||
fn parse_status_output(output: &[u8]) -> Result<(BranchInfo, Vec<GitFileStatus>), String> {
|
||||
let entries: Vec<&[u8]> = output
|
||||
.split(|byte| *byte == 0)
|
||||
@@ -3480,6 +3915,51 @@ mod tests {
|
||||
assert!(err.contains("existiert bereits"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rename_branch_renames_existing_local_branch() {
|
||||
let repo = init_temp_repo("rename_branch");
|
||||
commit_initial_file(&repo.path);
|
||||
let current = git_output_test(&repo.path, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||
run_git_test(&repo.path, ["branch", "feature/old-panel"]);
|
||||
|
||||
let status = rename_branch(
|
||||
repo.path.to_string_lossy().to_string(),
|
||||
"feature/old-panel".to_string(),
|
||||
"feature/new-panel".to_string(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(status.current_branch.as_deref(), Some(current.as_str()));
|
||||
assert!(
|
||||
!ref_exists(&repo.path, "refs/heads/feature/old-panel").unwrap(),
|
||||
"old branch should be gone"
|
||||
);
|
||||
assert!(
|
||||
ref_exists(&repo.path, "refs/heads/feature/new-panel").unwrap(),
|
||||
"new branch should exist"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn delete_branch_removes_local_branch_but_rejects_current_branch() {
|
||||
let repo = init_temp_repo("delete_branch");
|
||||
commit_initial_file(&repo.path);
|
||||
let current = git_output_test(&repo.path, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
||||
run_git_test(&repo.path, ["branch", "stale"]);
|
||||
|
||||
let status =
|
||||
delete_branch(repo.path.to_string_lossy().to_string(), "stale".to_string()).unwrap();
|
||||
|
||||
assert_eq!(status.current_branch.as_deref(), Some(current.as_str()));
|
||||
assert!(
|
||||
!ref_exists(&repo.path, "refs/heads/stale").unwrap(),
|
||||
"deleted branch should be gone"
|
||||
);
|
||||
|
||||
let err = delete_branch(repo.path.to_string_lossy().to_string(), current).unwrap_err();
|
||||
assert!(err.contains("aktuelle Branch"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn apply_file_patch_stages_and_discards_selected_changes() {
|
||||
let repo = init_temp_repo("apply_file_patch");
|
||||
@@ -3570,7 +4050,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restore_to_commit_resets_branch_to_selected_commit() {
|
||||
fn restore_to_commit_leaves_branch_untouched_and_stages_change_as_unstaged() {
|
||||
let repo = init_temp_repo("restore_to_commit");
|
||||
commit_initial_file(&repo.path);
|
||||
let first_commit = git_output_test(&repo.path, ["rev-parse", "HEAD"]);
|
||||
@@ -3578,6 +4058,7 @@ mod tests {
|
||||
fs::write(repo.path.join("old.txt"), "second\n").expect("second file should be written");
|
||||
run_git_test(&repo.path, ["add", "old.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "second"]);
|
||||
let second_commit = git_output_test(&repo.path, ["rev-parse", "HEAD"]);
|
||||
|
||||
let status = restore_to_commit(
|
||||
repo.path.to_string_lossy().to_string(),
|
||||
@@ -3587,9 +4068,20 @@ mod tests {
|
||||
let current_commit = git_output_test(&repo.path, ["rev-parse", "HEAD"]);
|
||||
let contents = fs::read_to_string(repo.path.join("old.txt")).unwrap();
|
||||
|
||||
assert_eq!(current_commit, first_commit);
|
||||
// The branch must stay exactly where it was: no commit is rewritten or hidden.
|
||||
assert_eq!(current_commit, second_commit);
|
||||
assert_ne!(current_commit, first_commit);
|
||||
// The old content lands in the worktree as a reviewable, unstaged change.
|
||||
assert_eq!(contents.replace("\r\n", "\n"), "original\n");
|
||||
assert!(status.clean, "{:?}", status.files);
|
||||
assert!(!status.clean, "{:?}", status.files);
|
||||
assert_eq!(
|
||||
status
|
||||
.files
|
||||
.iter()
|
||||
.find(|f| f.path == "old.txt")
|
||||
.and_then(|f| f.unstaged),
|
||||
Some(FileStatusKind::Modified)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3683,12 +4175,8 @@ mod tests {
|
||||
run_git_test(&repo.path, ["add", "other.txt"]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "touch other"]);
|
||||
|
||||
let commits = list_file_history(
|
||||
repo.path.to_string_lossy().to_string(),
|
||||
"old.txt".to_string(),
|
||||
Some(10),
|
||||
)
|
||||
.unwrap();
|
||||
let commits =
|
||||
list_file_history_core(&repo.path, "old.txt".to_string(), Some(10), None).unwrap();
|
||||
|
||||
assert_eq!(commits.len(), 2);
|
||||
assert_eq!(commits[0].summary, "touch selected");
|
||||
@@ -3711,15 +4199,34 @@ mod tests {
|
||||
run_git_test(&repo.path, ["add", "."]);
|
||||
run_git_test(&repo.path, ["commit", "-q", "-m", "src update"]);
|
||||
|
||||
let commits = list_file_history(
|
||||
repo.path.to_string_lossy().to_string(),
|
||||
"src".to_string(),
|
||||
Some(10),
|
||||
)
|
||||
.unwrap();
|
||||
let commits =
|
||||
list_file_history_core(&repo.path, "src".to_string(), Some(10), None).unwrap();
|
||||
|
||||
assert_eq!(commits.len(), 2);
|
||||
assert_eq!(commits[0].summary, "src update");
|
||||
assert_eq!(commits[1].summary, "src initial");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_file_history_can_be_cancelled() {
|
||||
let repo = init_temp_repo("file_history_cancelled");
|
||||
commit_initial_file(&repo.path);
|
||||
|
||||
let state = SearchCancellationState::default();
|
||||
state
|
||||
.cancel("file-history-test")
|
||||
.expect("cancel flag should be set");
|
||||
|
||||
let result = list_file_history_core(
|
||||
&repo.path,
|
||||
"old.txt".to_string(),
|
||||
Some(10),
|
||||
Some(&SearchCancellation {
|
||||
state,
|
||||
search_id: "file-history-test".to_string(),
|
||||
}),
|
||||
);
|
||||
|
||||
assert_eq!(result.unwrap_err(), SEARCH_CANCELLED_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-7
@@ -3,13 +3,15 @@
|
||||
mod git;
|
||||
|
||||
use git::{
|
||||
apply_file_patch, cancel_code_search, checkout_branch, commit, compare_commits,
|
||||
compare_file_to_head, compare_file_to_parent, create_branch, cred_delete, cred_load, cred_save,
|
||||
diff_file_against_working_tree, get_file_patch, get_remote_url, get_status, list_branches,
|
||||
list_commits, list_file_history, list_repository_files, merge_branch, open_repository,
|
||||
open_repository_bundle, pull, push, read_conflict, resolve_conflict, resolve_conflict_side,
|
||||
restore_file_from_commit, restore_files, restore_to_commit, search_code_introductions,
|
||||
stage_files, unstage_files, SearchCancellationState,
|
||||
apply_file_patch, cancel_code_search, cancel_file_history, checkout_branch, commit,
|
||||
compare_commits, compare_file_to_head, compare_file_to_parent, create_branch, cred_delete,
|
||||
cred_load, cred_save, delete_branch, diff_file_against_working_tree, get_file_patch,
|
||||
get_remote_url, get_status, list_branches, list_commits, list_file_history,
|
||||
list_repository_files, merge_branch, open_repo_in_explorer, open_repository,
|
||||
open_repository_bundle, open_repository_file, pull, push, read_conflict, rename_branch,
|
||||
resolve_conflict, resolve_conflict_side, restore_file_from_commit, restore_files,
|
||||
restore_to_commit, search_code_introductions, stage_files, unstage_files,
|
||||
SearchCancellationState,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
@@ -19,10 +21,14 @@ fn main() {
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
open_repository,
|
||||
open_repo_in_explorer,
|
||||
open_repository_file,
|
||||
get_status,
|
||||
list_branches,
|
||||
checkout_branch,
|
||||
create_branch,
|
||||
rename_branch,
|
||||
delete_branch,
|
||||
stage_files,
|
||||
unstage_files,
|
||||
restore_files,
|
||||
@@ -38,6 +44,7 @@ fn main() {
|
||||
list_repository_files,
|
||||
open_repository_bundle,
|
||||
list_file_history,
|
||||
cancel_file_history,
|
||||
compare_commits,
|
||||
compare_file_to_head,
|
||||
compare_file_to_parent,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "GitLite",
|
||||
"version": "2026.7.1",
|
||||
"version": "2026.7.5",
|
||||
"identifier": "com.git-lite",
|
||||
"build": {
|
||||
"beforeDevCommand": "npm run dev",
|
||||
|
||||
+540
-58
@@ -2,7 +2,7 @@
|
||||
import { onDestroy, onMount, tick } from "svelte";
|
||||
import { open as openDialog } from "@tauri-apps/plugin-dialog";
|
||||
import { check, type DownloadEvent, type Update } from "@tauri-apps/plugin-updater";
|
||||
import { AlertCircle, Check, FolderOpen, GitBranch, GitMerge, LoaderCircle } from "@lucide/svelte";
|
||||
import { AlertCircle, BookOpen, FolderOpen, GitBranch, GitMerge, LoaderCircle, Plus, Search, X } from "@lucide/svelte";
|
||||
|
||||
import TitleBar from "./lib/TitleBar.svelte";
|
||||
import BranchPanel from "./lib/components/BranchPanel.svelte";
|
||||
@@ -16,6 +16,7 @@
|
||||
import HistoryPanel from "./lib/components/HistoryPanel.svelte";
|
||||
import LinePatchDialog from "./lib/components/LinePatchDialog.svelte";
|
||||
import NewBranchDialog from "./lib/components/NewBranchDialog.svelte";
|
||||
import RenameBranchDialog from "./lib/components/RenameBranchDialog.svelte";
|
||||
import RepoLoadingOverlay from "./lib/components/RepoLoadingOverlay.svelte";
|
||||
import ResolveDialog from "./lib/components/ResolveDialog.svelte";
|
||||
import StatusPanel from "./lib/components/StatusPanel.svelte";
|
||||
@@ -26,8 +27,10 @@
|
||||
commit,
|
||||
compareCommits,
|
||||
cancelCodeSearch,
|
||||
cancelFileHistory,
|
||||
applyFilePatch,
|
||||
createBranch,
|
||||
deleteBranch,
|
||||
diffFileAgainstWorkingTree,
|
||||
compareFileToParent,
|
||||
getStatus,
|
||||
@@ -36,9 +39,12 @@
|
||||
listFileHistory,
|
||||
listRepositoryFiles,
|
||||
mergeBranch,
|
||||
openRepoInExplorer,
|
||||
openRepositoryFile,
|
||||
openRepositoryBundle,
|
||||
pull,
|
||||
push,
|
||||
renameBranch,
|
||||
getRemoteUrl,
|
||||
credLoad,
|
||||
credSave,
|
||||
@@ -81,11 +87,29 @@
|
||||
} from "./lib/credentials";
|
||||
|
||||
type UpdateToastState = "available" | "downloading" | "installed" | "error";
|
||||
type AppView = "management" | "repository";
|
||||
|
||||
interface RepoTab {
|
||||
path: string;
|
||||
name: string;
|
||||
branch: string | null;
|
||||
ahead: number;
|
||||
behind: number;
|
||||
changed: number;
|
||||
lastOpened: number;
|
||||
}
|
||||
|
||||
const OPEN_REPOS_KEY = "gitlite.openRepos.v1";
|
||||
const RECENT_REPOS_KEY = "gitlite.recentRepos.v1";
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
|
||||
let repoPath = "";
|
||||
let activeRepoPath = "";
|
||||
let activeView: AppView = "management";
|
||||
let repoTabs: RepoTab[] = [];
|
||||
let recentRepoPaths: string[] = [];
|
||||
let repoSearch = "";
|
||||
let status: GitStatus | null = null;
|
||||
let branches: GitBranchInfo[] = [];
|
||||
let commits: GitCommit[] = [];
|
||||
@@ -95,6 +119,9 @@
|
||||
let expandedExplorerPaths = new Set<string>();
|
||||
let expandedCommitHashes = new Set<string>();
|
||||
let fileHistory: GitCommit[] = [];
|
||||
let fileHistoryLoading = false;
|
||||
let fileHistoryRequestId = 0;
|
||||
let activeFileHistoryRequestId = "";
|
||||
let commitMessage = "";
|
||||
let errorMessage = "";
|
||||
let operation = "";
|
||||
@@ -102,6 +129,7 @@
|
||||
let compareTo = "";
|
||||
let comparison: GitCommitComparison | null = null;
|
||||
let newBranchCommit: GitCommit | null = null;
|
||||
let renameBranchTarget: GitBranchInfo | null = null;
|
||||
let compareSelectOpen = false;
|
||||
let compareDialogOpen = false;
|
||||
let selectedDiffPath = "";
|
||||
@@ -147,6 +175,7 @@
|
||||
|
||||
$: isBusy = operation.length > 0;
|
||||
$: hasRepository = activeRepoPath.length > 0 && status !== null;
|
||||
$: workspaceActive = activeView === "repository" && hasRepository;
|
||||
$: openingRepo = operation === "Opening repository";
|
||||
$: repoDisplayName = ((repoPath || activeRepoPath).split(/[\\/]/).filter(Boolean).pop()) ?? "";
|
||||
$: changedFiles = status?.files ?? [];
|
||||
@@ -161,16 +190,27 @@
|
||||
$: canCompare = hasRepository && compareFrom.length > 0 && compareTo.length > 0 && compareFrom !== compareTo && !isBusy;
|
||||
$: localBranches = branches.filter((b) => !b.remote);
|
||||
$: remoteBranches = branches.filter((b) => b.remote);
|
||||
$: repoSearchTerm = repoSearch.trim().toLowerCase();
|
||||
$: openRepoRows = repoTabs.filter(repoMatchesSearch);
|
||||
$: recentRepoRows = recentRepoPaths
|
||||
.filter((path) => !repoTabs.some((tab) => sameRepoPath(tab.path, path)))
|
||||
.map(repoRowFromPath)
|
||||
.filter(repoMatchesSearch);
|
||||
$: allRepoRows = uniqueRepoPaths([...repoTabs.map((tab) => tab.path), ...recentRepoPaths])
|
||||
.map(repoRowFromPath)
|
||||
.filter(repoMatchesSearch);
|
||||
|
||||
// ── Lifecycle ──────────────────────────────────────────────────────────────
|
||||
|
||||
onMount(() => {
|
||||
loadRepoLists();
|
||||
autoRefreshTimer = setInterval(() => { void autoRefreshTick(); }, AUTO_REFRESH_INTERVAL);
|
||||
void checkForUpdates();
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (autoRefreshTimer) clearInterval(autoRefreshTimer);
|
||||
if (activeFileHistoryRequestId) void cancelFileHistory(activeFileHistoryRequestId);
|
||||
});
|
||||
|
||||
// ── Auto-refresh ───────────────────────────────────────────────────────────
|
||||
@@ -180,7 +220,7 @@
|
||||
}
|
||||
|
||||
async function autoRefreshTick() {
|
||||
if (!autoRefreshEnabled || !activeRepoPath || isBusy || autoRefreshInFlight || resolveDialogOpen || compareDialogOpen || compareSelectOpen || newBranchCommit || globalSearchOpen) return;
|
||||
if (!autoRefreshEnabled || activeView !== "repository" || !activeRepoPath || isBusy || autoRefreshInFlight || resolveDialogOpen || compareDialogOpen || compareSelectOpen || newBranchCommit || globalSearchOpen) return;
|
||||
autoRefreshInFlight = true;
|
||||
try {
|
||||
// Cheap fast path: only fetch status; skip the heavy reload if nothing changed.
|
||||
@@ -277,11 +317,148 @@
|
||||
|
||||
// ── Utilities ──────────────────────────────────────────────────────────────
|
||||
|
||||
function repoNameFromPath(path: string): string {
|
||||
return path.split(/[\\/]/).filter(Boolean).pop() ?? path;
|
||||
}
|
||||
|
||||
function repoKey(path: string): string {
|
||||
return path.replace(/\\/g, "/").trim().toLowerCase();
|
||||
}
|
||||
|
||||
function sameRepoPath(left: string, right: string): boolean {
|
||||
return repoKey(left) === repoKey(right);
|
||||
}
|
||||
|
||||
function uniqueRepoPaths(paths: string[]): string[] {
|
||||
const seen = new Set<string>();
|
||||
const result: string[] = [];
|
||||
for (const path of paths) {
|
||||
const trimmed = path.trim();
|
||||
if (!trimmed) continue;
|
||||
const key = repoKey(trimmed);
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
result.push(trimmed);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function repoRowFromPath(path: string): RepoTab {
|
||||
return repoTabs.find((tab) => sameRepoPath(tab.path, path)) ?? {
|
||||
path,
|
||||
name: repoNameFromPath(path),
|
||||
branch: null,
|
||||
ahead: 0,
|
||||
behind: 0,
|
||||
changed: 0,
|
||||
lastOpened: 0,
|
||||
};
|
||||
}
|
||||
|
||||
function repoMatchesSearch(repo: RepoTab): boolean {
|
||||
if (!repoSearchTerm) return true;
|
||||
return repo.name.toLowerCase().includes(repoSearchTerm)
|
||||
|| repo.path.toLowerCase().includes(repoSearchTerm)
|
||||
|| (repo.branch ?? "").toLowerCase().includes(repoSearchTerm);
|
||||
}
|
||||
|
||||
function loadRepoLists() {
|
||||
try {
|
||||
const openValue = JSON.parse(localStorage.getItem(OPEN_REPOS_KEY) ?? "[]") as unknown;
|
||||
const recentValue = JSON.parse(localStorage.getItem(RECENT_REPOS_KEY) ?? "[]") as unknown;
|
||||
const openPaths = Array.isArray(openValue)
|
||||
? openValue.map((item) => typeof item === "string" ? item : "").filter(Boolean)
|
||||
: [];
|
||||
const recentPaths = Array.isArray(recentValue)
|
||||
? recentValue.map((item) => typeof item === "string" ? item : "").filter(Boolean)
|
||||
: [];
|
||||
|
||||
repoTabs = uniqueRepoPaths(openPaths).map((path) => ({
|
||||
path,
|
||||
name: repoNameFromPath(path),
|
||||
branch: null,
|
||||
ahead: 0,
|
||||
behind: 0,
|
||||
changed: 0,
|
||||
lastOpened: 0,
|
||||
}));
|
||||
recentRepoPaths = uniqueRepoPaths([...recentPaths, ...openPaths]);
|
||||
} catch {
|
||||
repoTabs = [];
|
||||
recentRepoPaths = [];
|
||||
}
|
||||
}
|
||||
|
||||
function persistRepoLists() {
|
||||
try {
|
||||
localStorage.setItem(OPEN_REPOS_KEY, JSON.stringify(repoTabs.map((tab) => tab.path)));
|
||||
localStorage.setItem(RECENT_REPOS_KEY, JSON.stringify(recentRepoPaths));
|
||||
} catch {
|
||||
// Local storage is best-effort only; the Git workflow must keep working without it.
|
||||
}
|
||||
}
|
||||
|
||||
function rememberRecentRepo(path: string) {
|
||||
recentRepoPaths = uniqueRepoPaths([path, ...recentRepoPaths]).slice(0, 40);
|
||||
persistRepoLists();
|
||||
}
|
||||
|
||||
function upsertRepoTab(path: string, nextStatus?: GitStatus | null) {
|
||||
const existing = repoTabs.find((tab) => sameRepoPath(tab.path, path));
|
||||
const next: RepoTab = {
|
||||
path,
|
||||
name: repoNameFromPath(path),
|
||||
branch: nextStatus?.current_branch ?? existing?.branch ?? null,
|
||||
ahead: nextStatus?.ahead ?? existing?.ahead ?? 0,
|
||||
behind: nextStatus?.behind ?? existing?.behind ?? 0,
|
||||
changed: nextStatus?.files.length ?? existing?.changed ?? 0,
|
||||
lastOpened: Date.now(),
|
||||
};
|
||||
|
||||
repoTabs = existing
|
||||
? repoTabs.map((tab) => sameRepoPath(tab.path, path) ? next : tab)
|
||||
: [...repoTabs, next];
|
||||
rememberRecentRepo(path);
|
||||
}
|
||||
|
||||
function resetRepositoryState(clearActive = false) {
|
||||
if (clearActive) {
|
||||
activeRepoPath = "";
|
||||
repoPath = "";
|
||||
status = null;
|
||||
lastStatusFingerprint = "";
|
||||
}
|
||||
branches = [];
|
||||
commits = [];
|
||||
repoFiles = [];
|
||||
selectedExplorerPath = "";
|
||||
selectedExplorerKind = "file";
|
||||
expandedExplorerPaths = new Set();
|
||||
expandedCommitHashes = new Set();
|
||||
fileHistory = [];
|
||||
compareFrom = "";
|
||||
compareTo = "";
|
||||
comparison = null;
|
||||
compareSelectOpen = false;
|
||||
compareDialogOpen = false;
|
||||
selectedDiffPath = "";
|
||||
pendingRestoreFile = null;
|
||||
newBranchCommit = null;
|
||||
globalSearchResults = [];
|
||||
globalSearchOpen = false;
|
||||
globalSearchError = "";
|
||||
resolveDialogOpen = false;
|
||||
conflictTarget = "";
|
||||
conflict = null;
|
||||
preparedResolutions = {};
|
||||
}
|
||||
|
||||
function applyStatus(nextStatus: GitStatus) {
|
||||
status = nextStatus;
|
||||
activeRepoPath = nextStatus.repo_path || activeRepoPath || repoPath.trim();
|
||||
repoPath = activeRepoPath;
|
||||
lastStatusFingerprint = statusFingerprint(nextStatus);
|
||||
upsertRepoTab(activeRepoPath, nextStatus);
|
||||
}
|
||||
|
||||
function errorToMessage(error: unknown): string {
|
||||
@@ -361,12 +538,56 @@
|
||||
if (selectedExplorerPath && !explorerPathExists(repoFiles, selectedExplorerPath)) {
|
||||
selectedExplorerPath = "";
|
||||
selectedExplorerKind = "file";
|
||||
cancelActiveFileHistoryLoad();
|
||||
activeFileHistoryRequestId = "";
|
||||
fileHistoryLoading = false;
|
||||
fileHistory = [];
|
||||
}
|
||||
}
|
||||
|
||||
function isCancellationMessage(message: string): boolean {
|
||||
return message.toLowerCase().includes("abgebrochen");
|
||||
}
|
||||
|
||||
function cancelActiveFileHistoryLoad() {
|
||||
const requestId = activeFileHistoryRequestId;
|
||||
if (!requestId) return;
|
||||
void cancelFileHistory(requestId).catch(() => {});
|
||||
}
|
||||
|
||||
async function refreshFileHistory(path = activeRepoPath, file = selectedExplorerPath) {
|
||||
fileHistory = file ? await listFileHistory(path, file, 100) : [];
|
||||
const requestId = ++fileHistoryRequestId;
|
||||
cancelActiveFileHistoryLoad();
|
||||
|
||||
if (!path || !file) {
|
||||
activeFileHistoryRequestId = "";
|
||||
fileHistoryLoading = false;
|
||||
fileHistory = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const historyRequestId = `file-history-${requestId}-${Date.now()}`;
|
||||
activeFileHistoryRequestId = historyRequestId;
|
||||
fileHistoryLoading = true;
|
||||
fileHistory = [];
|
||||
|
||||
try {
|
||||
const history = await listFileHistory(path, file, 100, historyRequestId);
|
||||
if (requestId === fileHistoryRequestId && activeFileHistoryRequestId === historyRequestId) {
|
||||
fileHistory = history;
|
||||
}
|
||||
} catch (error) {
|
||||
const message = errorToMessage(error);
|
||||
if (requestId === fileHistoryRequestId && activeFileHistoryRequestId === historyRequestId) {
|
||||
fileHistory = [];
|
||||
if (!isCancellationMessage(message)) errorMessage = message;
|
||||
}
|
||||
} finally {
|
||||
if (requestId === fileHistoryRequestId && activeFileHistoryRequestId === historyRequestId) {
|
||||
activeFileHistoryRequestId = "";
|
||||
fileHistoryLoading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Repository operations ──────────────────────────────────────────────────
|
||||
@@ -385,17 +606,10 @@
|
||||
// Single backend round-trip: resolves the repo and reads status, branches,
|
||||
// commits and files in one pass instead of four sequential git calls.
|
||||
const bundle = await openRepositoryBundle(path, 100);
|
||||
resetRepositoryState(false);
|
||||
applyStatus(bundle.status);
|
||||
branches = []; commits = []; repoFiles = [];
|
||||
selectedExplorerPath = ""; selectedExplorerKind = "file";
|
||||
expandedExplorerPaths = new Set(); expandedCommitHashes = new Set();
|
||||
fileHistory = []; compareFrom = ""; compareTo = "";
|
||||
comparison = null; compareSelectOpen = false; compareDialogOpen = false; selectedDiffPath = ""; pendingRestoreFile = null;
|
||||
newBranchCommit = null;
|
||||
if (globalSearchBusy) void cancelGlobalSearch();
|
||||
globalSearchResults = []; globalSearchOpen = false; globalSearchError = "";
|
||||
resolveDialogOpen = false; conflictTarget = ""; conflict = null;
|
||||
preparedResolutions = {};
|
||||
activeView = "repository";
|
||||
await refreshBranchList(activeRepoPath, bundle.branches);
|
||||
await refreshCommitHistory(activeRepoPath, bundle.commits);
|
||||
await refreshExplorerFiles(activeRepoPath, bundle.files);
|
||||
@@ -419,6 +633,55 @@
|
||||
}
|
||||
}
|
||||
|
||||
function openRepoManagement() {
|
||||
if (isBusy) return;
|
||||
activeView = "management";
|
||||
}
|
||||
|
||||
async function selectRepoTab(path: string) {
|
||||
if (isBusy) return;
|
||||
if (activeView === "repository" && sameRepoPath(activeRepoPath, path)) return;
|
||||
await openRepo(path);
|
||||
}
|
||||
|
||||
async function closeRepoTab(path: string, event?: MouseEvent) {
|
||||
event?.stopPropagation();
|
||||
if (isBusy) return;
|
||||
|
||||
const index = repoTabs.findIndex((tab) => sameRepoPath(tab.path, path));
|
||||
const remaining = repoTabs.filter((tab) => !sameRepoPath(tab.path, path));
|
||||
const next = remaining[index] ?? remaining[index - 1] ?? null;
|
||||
repoTabs = remaining;
|
||||
persistRepoLists();
|
||||
|
||||
if (!sameRepoPath(activeRepoPath, path)) return;
|
||||
if (next) {
|
||||
await openRepo(next.path);
|
||||
} else {
|
||||
resetRepositoryState(true);
|
||||
activeView = "management";
|
||||
}
|
||||
}
|
||||
|
||||
async function removeRepoFromManagement(path: string, event?: MouseEvent) {
|
||||
event?.stopPropagation();
|
||||
if (isBusy) return;
|
||||
recentRepoPaths = recentRepoPaths.filter((recentPath) => !sameRepoPath(recentPath, path));
|
||||
persistRepoLists();
|
||||
if (repoTabs.some((tab) => sameRepoPath(tab.path, path))) {
|
||||
await closeRepoTab(path);
|
||||
}
|
||||
}
|
||||
|
||||
async function openActiveRepoInExplorer() {
|
||||
if (!activeRepoPath || isBusy) return;
|
||||
try {
|
||||
await openRepoInExplorer(activeRepoPath);
|
||||
} catch (error) {
|
||||
errorMessage = errorToMessage(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshRepo() {
|
||||
if (!activeRepoPath) { await openRepo(); return; }
|
||||
await runOperation("Refreshing", async () => {
|
||||
@@ -453,6 +716,45 @@
|
||||
});
|
||||
}
|
||||
|
||||
function renameLocalBranch(branch: GitBranchInfo) {
|
||||
if (!activeRepoPath || branch.remote) return;
|
||||
renameBranchTarget = branch;
|
||||
}
|
||||
|
||||
async function submitRenameBranch(branchName: string) {
|
||||
const branch = renameBranchTarget;
|
||||
const name = branchName.trim();
|
||||
if (!activeRepoPath || !branch || branch.remote || !name || name === branch.name) return;
|
||||
|
||||
await runOperation(`Renaming ${branch.name}`, async () => {
|
||||
applyStatus(await renameBranch(activeRepoPath, branch.name, name));
|
||||
renameBranchTarget = null;
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteLocalBranch(branch: GitBranchInfo) {
|
||||
if (!activeRepoPath || branch.remote) return;
|
||||
if (branch.current) {
|
||||
errorMessage = "The current branch cannot be deleted.";
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmed = window.confirm(`Delete local branch "${branch.name}"?\n\nGit will refuse if the branch has unmerged changes.`);
|
||||
if (!confirmed) return;
|
||||
|
||||
await runOperation(`Deleting ${branch.name}`, async () => {
|
||||
applyStatus(await deleteBranch(activeRepoPath, branch.name));
|
||||
await refreshBranchList(activeRepoPath);
|
||||
await refreshCommitHistory(activeRepoPath);
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
await refreshFileHistory(activeRepoPath);
|
||||
});
|
||||
}
|
||||
|
||||
function openNewBranchDialog(commit: GitCommit) {
|
||||
if (!activeRepoPath || isBusy) return;
|
||||
newBranchCommit = commit;
|
||||
@@ -795,7 +1097,7 @@
|
||||
|
||||
async function restoreCommit(target: GitCommit) {
|
||||
if (!activeRepoPath) return;
|
||||
const confirmed = window.confirm(`Reset current branch to ${target.short_hash}?\n\nThis moves the current branch and discards tracked local changes.`);
|
||||
const confirmed = window.confirm(`Restore working tree to ${target.short_hash}?\n\nThis brings back the files from that commit as unstaged changes so you can review and commit them. No commit is removed and the branch stays where it is.`);
|
||||
if (!confirmed) return;
|
||||
await runOperation(`Restoring ${target.short_hash}`, async () => {
|
||||
applyStatus(await restoreToCommit(activeRepoPath, target.hash));
|
||||
@@ -860,13 +1162,18 @@
|
||||
return folders;
|
||||
}
|
||||
|
||||
// Loads history for a selected explorer node without blocking the rest of the UI
|
||||
// (isBusy/runOperation would disable every button in the app while this awaits).
|
||||
// A request id guards against a slower, stale request overwriting a newer selection.
|
||||
async function loadSelectedFileHistory(path: string, repo = activeRepoPath) {
|
||||
await refreshFileHistory(repo, path);
|
||||
}
|
||||
|
||||
async function selectExplorerNode(node: ExplorerNode) {
|
||||
if (!activeRepoPath || (selectedExplorerPath === node.path && selectedExplorerKind === node.kind)) return;
|
||||
selectedExplorerPath = node.path;
|
||||
selectedExplorerKind = node.kind;
|
||||
await runOperation(`Loading ${node.path} history`, async () => {
|
||||
await refreshFileHistory(activeRepoPath, node.path);
|
||||
});
|
||||
void loadSelectedFileHistory(node.path);
|
||||
}
|
||||
|
||||
async function selectFileFromSearch(file: GitRepositoryFile) {
|
||||
@@ -875,9 +1182,29 @@
|
||||
selectedExplorerKind = "file";
|
||||
expandedExplorerPaths = new Set([...expandedExplorerPaths, ...explorerParentFolders(file.path)]);
|
||||
|
||||
await runOperation(`Loading ${file.path} history`, async () => {
|
||||
await refreshFileHistory(activeRepoPath, file.path);
|
||||
});
|
||||
void loadSelectedFileHistory(file.path);
|
||||
}
|
||||
|
||||
function selectFileFromStatus(file: GitFileStatus) {
|
||||
if (!activeRepoPath) return;
|
||||
selectedExplorerPath = file.path;
|
||||
selectedExplorerKind = "file";
|
||||
expandedExplorerPaths = new Set([...expandedExplorerPaths, ...explorerParentFolders(file.path)]);
|
||||
|
||||
void loadSelectedFileHistory(file.path);
|
||||
}
|
||||
|
||||
async function openFileFromExplorer(node: ExplorerNode) {
|
||||
if (!activeRepoPath || node.kind !== "file") return;
|
||||
selectedExplorerPath = node.path;
|
||||
selectedExplorerKind = "file";
|
||||
void loadSelectedFileHistory(node.path);
|
||||
|
||||
try {
|
||||
await openRepositoryFile(activeRepoPath, node.path);
|
||||
} catch (error) {
|
||||
errorMessage = errorToMessage(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function restoreSelectedFileFromCommit(target: GitCommit) {
|
||||
@@ -1059,21 +1386,24 @@
|
||||
|
||||
// ── Event handlers ─────────────────────────────────────────────────────────
|
||||
|
||||
function submitRepo(event: SubmitEvent) { event.preventDefault(); void openRepo(); }
|
||||
|
||||
function handleWindowKeydown(event: KeyboardEvent) {
|
||||
if (event.key === "Escape" && compareDialogOpen) closeCompareDialog();
|
||||
else if (event.key === "Escape" && newBranchCommit) newBranchCommit = null;
|
||||
else if (event.key === "Escape" && renameBranchTarget) renameBranchTarget = null;
|
||||
else if (event.key === "Escape" && compareSelectOpen) compareSelectOpen = false;
|
||||
else if (event.key === "Escape" && globalSearchOpen) closeGlobalSearchDialog();
|
||||
}
|
||||
|
||||
function handleWindowContextMenu(event: MouseEvent) {
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>GitLite</title>
|
||||
</svelte:head>
|
||||
|
||||
<svelte:window on:keydown={handleWindowKeydown} />
|
||||
<svelte:window on:keydown={handleWindowKeydown} on:contextmenu={handleWindowContextMenu} />
|
||||
|
||||
<main class="shell">
|
||||
<TitleBar
|
||||
@@ -1081,7 +1411,7 @@
|
||||
ahead={status?.ahead ?? 0}
|
||||
behind={status?.behind ?? 0}
|
||||
repoName={activeRepoPath ? (activeRepoPath.split(/[\\/]/).filter(Boolean).slice(-1)[0] ?? "") : ""}
|
||||
{hasRepository}
|
||||
hasRepository={workspaceActive}
|
||||
{isBusy}
|
||||
{operation}
|
||||
{autoRefreshEnabled}
|
||||
@@ -1091,43 +1421,65 @@
|
||||
onRefresh={refreshRepo}
|
||||
onSearch={() => { globalSearchOpen = true; }}
|
||||
onCompare={openCompareSelect}
|
||||
onOpenInExplorer={openActiveRepoInExplorer}
|
||||
onToggleAutoRefresh={toggleAutoRefresh}
|
||||
/>
|
||||
|
||||
<div class="shell-body">
|
||||
|
||||
<!-- Repository path form -->
|
||||
<header class="topbar">
|
||||
<form class="repo-form" onsubmit={submitRepo}>
|
||||
<label for="repo-path">Repository</label>
|
||||
<input
|
||||
id="repo-path"
|
||||
bind:value={repoPath}
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
placeholder="/path/to/repository"
|
||||
disabled={isBusy}
|
||||
/>
|
||||
<button
|
||||
class="btn-secondary repo-browse"
|
||||
type="button"
|
||||
onclick={chooseRepositoryFolder}
|
||||
disabled={isBusy}
|
||||
title="Repository-Ordner auswaehlen"
|
||||
aria-label="Repository-Ordner auswaehlen"
|
||||
>
|
||||
<FolderOpen size={16} aria-hidden="true" />
|
||||
Browse
|
||||
</button>
|
||||
<button class="btn-primary" type="submit" disabled={isBusy || repoPath.trim().length === 0}>
|
||||
{#if operation === "Opening repository"}
|
||||
<LoaderCircle class="spin" size={16} aria-hidden="true" />
|
||||
{:else}
|
||||
<Check size={16} aria-hidden="true" />
|
||||
{/if}
|
||||
Open
|
||||
</button>
|
||||
</form>
|
||||
<header class="repo-tabbar" aria-label="Repository tabs">
|
||||
<button
|
||||
class="repo-tab management"
|
||||
class:active={activeView === "management"}
|
||||
type="button"
|
||||
onclick={openRepoManagement}
|
||||
disabled={isBusy}
|
||||
title="Repository Management"
|
||||
>
|
||||
<BookOpen size={14} aria-hidden="true" />
|
||||
Repository Management
|
||||
</button>
|
||||
|
||||
<div class="repo-tabs-scroll">
|
||||
{#each repoTabs as repo (repo.path)}
|
||||
<div class="repo-tab-wrap" class:active={activeView === "repository" && sameRepoPath(activeRepoPath, repo.path)}>
|
||||
<button
|
||||
class="repo-tab"
|
||||
type="button"
|
||||
onclick={() => selectRepoTab(repo.path)}
|
||||
disabled={isBusy}
|
||||
title={repo.path}
|
||||
>
|
||||
<FolderOpen size={14} aria-hidden="true" />
|
||||
<span>{repo.name}</span>
|
||||
{#if repo.branch}
|
||||
<strong>{repo.branch}</strong>
|
||||
{/if}
|
||||
</button>
|
||||
<button
|
||||
class="repo-tab-close"
|
||||
type="button"
|
||||
onclick={(event) => closeRepoTab(repo.path, event)}
|
||||
disabled={isBusy}
|
||||
aria-label={`Close ${repo.name}`}
|
||||
title="Close repository tab"
|
||||
>
|
||||
<X size={13} aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="repo-tab-add"
|
||||
type="button"
|
||||
onclick={chooseRepositoryFolder}
|
||||
disabled={isBusy}
|
||||
title="Open repository folder"
|
||||
aria-label="Open repository folder"
|
||||
>
|
||||
<Plus size={15} aria-hidden="true" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<!-- Status notices -->
|
||||
@@ -1145,7 +1497,7 @@
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{#if hasConflicts}
|
||||
{#if workspaceActive && hasConflicts}
|
||||
<section class="notice conflict" role="alert">
|
||||
<GitMerge size={17} aria-hidden="true" />
|
||||
<span>{conflictedFiles.length} {conflictedFiles.length === 1 ? "file has" : "files have"} merge conflicts.</span>
|
||||
@@ -1153,8 +1505,121 @@
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<!-- Workspace -->
|
||||
<section class="workspace" aria-label="Git workspace">
|
||||
{#if activeView === "management"}
|
||||
<section class="repo-management" aria-label="Repository Management">
|
||||
<div class="repo-management-head">
|
||||
<div>
|
||||
<span class="eyebrow">Repository Management</span>
|
||||
<h1>Repositories</h1>
|
||||
</div>
|
||||
<div class="repo-management-actions">
|
||||
<button class="btn-secondary" type="button" onclick={chooseRepositoryFolder} disabled={isBusy}>
|
||||
<FolderOpen size={15} aria-hidden="true" />
|
||||
Browse
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="repo-management-tools">
|
||||
<div class="repo-search">
|
||||
<Search size={15} aria-hidden="true" />
|
||||
<input
|
||||
bind:value={repoSearch}
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
placeholder="Search repositories"
|
||||
aria-label="Search repositories"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="repo-sections">
|
||||
<section class="repo-section">
|
||||
<header>
|
||||
<h2>Open repositories</h2>
|
||||
<span>{openRepoRows.length}</span>
|
||||
</header>
|
||||
{#if openRepoRows.length === 0}
|
||||
<div class="repo-empty">No open repositories.</div>
|
||||
{:else}
|
||||
<div class="repo-table">
|
||||
{#each openRepoRows as repo (repo.path)}
|
||||
<div class="repo-row">
|
||||
<button class="repo-row-main" type="button" onclick={() => selectRepoTab(repo.path)} disabled={isBusy}>
|
||||
<span class="repo-row-name">{repo.name}</span>
|
||||
<span class="repo-row-path">{repo.path}</span>
|
||||
<span class="repo-row-meta">
|
||||
{#if repo.branch}<strong><GitBranch size={11} aria-hidden="true" />{repo.branch}</strong>{/if}
|
||||
{#if repo.ahead > 0}<em class="ahead">↑ {repo.ahead}</em>{/if}
|
||||
{#if repo.behind > 0}<em class="behind">↓ {repo.behind}</em>{/if}
|
||||
{#if repo.changed > 0}<em>{repo.changed} changed</em>{/if}
|
||||
</span>
|
||||
</button>
|
||||
<button class="repo-row-icon" type="button" onclick={(event) => closeRepoTab(repo.path, event)} disabled={isBusy} title="Close tab" aria-label={`Close ${repo.name}`}>
|
||||
<X size={14} aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<section class="repo-section">
|
||||
<header>
|
||||
<h2>Recent repositories</h2>
|
||||
<span>{recentRepoRows.length}</span>
|
||||
</header>
|
||||
{#if recentRepoRows.length === 0}
|
||||
<div class="repo-empty">No recent repositories.</div>
|
||||
{:else}
|
||||
<div class="repo-table">
|
||||
{#each recentRepoRows as repo (repo.path)}
|
||||
<div class="repo-row">
|
||||
<button class="repo-row-main" type="button" onclick={() => openRepo(repo.path)} disabled={isBusy}>
|
||||
<span class="repo-row-name">{repo.name}</span>
|
||||
<span class="repo-row-path">{repo.path}</span>
|
||||
<span class="repo-row-meta quiet">recent</span>
|
||||
</button>
|
||||
<button class="repo-row-icon" type="button" onclick={(event) => removeRepoFromManagement(repo.path, event)} disabled={isBusy} title="Remove from recent" aria-label={`Remove ${repo.name}`}>
|
||||
<X size={14} aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<section class="repo-section">
|
||||
<header>
|
||||
<h2>All repositories</h2>
|
||||
<span>{allRepoRows.length}</span>
|
||||
</header>
|
||||
{#if allRepoRows.length === 0}
|
||||
<div class="repo-empty">Browse for a repository to add it here.</div>
|
||||
{:else}
|
||||
<div class="repo-table">
|
||||
{#each allRepoRows as repo (repo.path)}
|
||||
<div class="repo-row">
|
||||
<button class="repo-row-main" type="button" onclick={() => openRepo(repo.path)} disabled={isBusy}>
|
||||
<span class="repo-row-name">{repo.name}</span>
|
||||
<span class="repo-row-path">{repo.path}</span>
|
||||
<span class="repo-row-meta">
|
||||
{#if repo.branch}<strong><GitBranch size={11} aria-hidden="true" />{repo.branch}</strong>{:else}<em>known repo</em>{/if}
|
||||
</span>
|
||||
</button>
|
||||
<button class="repo-row-icon" type="button" onclick={(event) => removeRepoFromManagement(repo.path, event)} disabled={isBusy} title="Remove" aria-label={`Remove ${repo.name}`}>
|
||||
<X size={14} aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
{:else}
|
||||
<!-- Workspace -->
|
||||
<section class="workspace" aria-label="Git workspace">
|
||||
|
||||
<!-- Left sidebar: branches + explorer -->
|
||||
<aside class="left-sidebar" aria-label="Repository navigation">
|
||||
@@ -1167,6 +1632,8 @@
|
||||
onCheckout={checkout}
|
||||
onMerge={merge}
|
||||
onCreateBranch={createNewBranch}
|
||||
onRenameBranch={renameLocalBranch}
|
||||
onDeleteBranch={deleteLocalBranch}
|
||||
/>
|
||||
<ExplorerPanel
|
||||
{repoFiles}
|
||||
@@ -1179,6 +1646,7 @@
|
||||
onExpandAllFolders={expandAllExplorerFolders}
|
||||
onCollapseAllFolders={collapseAllExplorerFolders}
|
||||
onSelectNode={selectExplorerNode}
|
||||
onOpenFile={openFileFromExplorer}
|
||||
/>
|
||||
</aside>
|
||||
|
||||
@@ -1207,6 +1675,8 @@
|
||||
{hasRepository}
|
||||
{isBusy}
|
||||
{status}
|
||||
selectedFilePath={selectedExplorerPath}
|
||||
onSelectFile={selectFileFromStatus}
|
||||
onStage={stageFile}
|
||||
onUnstage={unstageFile}
|
||||
onDiscard={discardFile}
|
||||
@@ -1250,11 +1720,13 @@
|
||||
selectedExplorerLabel={selectedExplorerPath ? `${selectedExplorerKind === "folder" ? "Folder" : "File"} history` : "File history"}
|
||||
{hasRepository}
|
||||
{isBusy}
|
||||
isLoading={fileHistoryLoading}
|
||||
onDiff={diffSelectedFileFromCommit}
|
||||
onRestore={restoreSelectedFileFromCommit}
|
||||
/>
|
||||
</aside>
|
||||
</section>
|
||||
{/if}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
@@ -1315,6 +1787,16 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Rename a local branch from the branch context menu -->
|
||||
{#if renameBranchTarget}
|
||||
<RenameBranchDialog
|
||||
branch={renameBranchTarget}
|
||||
{isBusy}
|
||||
onRename={submitRenameBranch}
|
||||
onClose={() => { renameBranchTarget = null; }}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<!-- Compare: pick the two commits to diff -->
|
||||
{#if compareSelectOpen}
|
||||
<CompareSelectDialog
|
||||
|
||||
+502
@@ -12,6 +12,7 @@
|
||||
--color-surface-dim: rgba(18, 18, 30, 0.9);
|
||||
--color-surface-hover: rgba(47, 48, 78, 0.76);
|
||||
--color-surface-raised: rgba(28, 29, 48, 0.88);
|
||||
--color-surface-solid: #1c1d30;
|
||||
|
||||
--color-border: rgba(100, 108, 255, 0.28);
|
||||
--color-border-subtle: rgba(255, 255, 255, 0.08);
|
||||
@@ -274,6 +275,15 @@
|
||||
}
|
||||
.titlebar-brand svg { color: #ffd343; filter: drop-shadow(0 0 10px rgba(255,211,67,0.3)); flex-shrink: 0; }
|
||||
|
||||
.tb-version {
|
||||
margin-left: 1px;
|
||||
color: rgba(255,255,255,0.32);
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
font-family: var(--font-mono);
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
.titlebar-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -365,6 +375,271 @@
|
||||
.repo-form label { color: var(--color-ink-faint); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
|
||||
.repo-browse { min-width: 104px; }
|
||||
|
||||
/* --- Repository tabs + management --- */
|
||||
|
||||
.repo-tabbar {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
align-items: stretch;
|
||||
min-height: 40px;
|
||||
border: 1px solid var(--color-border-subtle);
|
||||
border-radius: 10px;
|
||||
background: rgba(16, 17, 29, 0.9);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.repo-tabs-scroll {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
|
||||
.repo-tab-wrap {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
min-width: 0;
|
||||
border-right: 1px solid var(--color-border-subtle);
|
||||
background: rgba(255,255,255,0.015);
|
||||
}
|
||||
.repo-tab-wrap.active {
|
||||
background: rgba(90, 140, 248, 0.16);
|
||||
box-shadow: inset 0 -2px 0 var(--color-primary);
|
||||
}
|
||||
|
||||
.repo-tab {
|
||||
min-height: 38px;
|
||||
min-width: 0;
|
||||
max-width: 250px;
|
||||
padding: 0 10px;
|
||||
border: 0;
|
||||
border-right: 1px solid var(--color-border-subtle);
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--color-ink-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.repo-tab.management {
|
||||
max-width: none;
|
||||
min-width: 190px;
|
||||
}
|
||||
.repo-tab.active,
|
||||
.repo-tab-wrap.active .repo-tab {
|
||||
color: var(--color-ink);
|
||||
}
|
||||
.repo-tab span {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.repo-tab strong {
|
||||
flex: 0 0 auto;
|
||||
max-width: 90px;
|
||||
overflow: hidden;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
background: rgba(94, 110, 156, 0.18);
|
||||
color: var(--color-ink-dim);
|
||||
font-size: 10.5px;
|
||||
font-family: var(--font-mono);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.repo-tab-close,
|
||||
.repo-tab-add {
|
||||
min-height: 38px;
|
||||
min-width: 38px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--color-ink-faint);
|
||||
}
|
||||
.repo-tab-add {
|
||||
border-left: 1px solid var(--color-border-subtle);
|
||||
}
|
||||
|
||||
.repo-management {
|
||||
display: grid;
|
||||
grid-template-rows: auto auto minmax(0, 1fr);
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 12px;
|
||||
background: rgba(20, 21, 34, 0.82);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.repo-management-head,
|
||||
.repo-management-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--color-border-subtle);
|
||||
background: var(--color-surface-dim);
|
||||
}
|
||||
.repo-management-head h1 {
|
||||
margin: 2px 0 0;
|
||||
color: var(--color-ink);
|
||||
font-size: 18px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.repo-management-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.repo-management-tools {
|
||||
padding: 9px 16px;
|
||||
background: rgba(12, 13, 24, 0.72);
|
||||
}
|
||||
.repo-search {
|
||||
position: relative;
|
||||
width: min(620px, 100%);
|
||||
}
|
||||
.repo-search svg {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 50%;
|
||||
color: var(--color-ink-faint);
|
||||
transform: translateY(-50%);
|
||||
pointer-events: none;
|
||||
}
|
||||
.repo-search input {
|
||||
padding-left: 34px;
|
||||
}
|
||||
|
||||
.repo-sections {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 14px 16px 18px;
|
||||
}
|
||||
|
||||
.repo-section {
|
||||
border: 1px solid var(--color-border-subtle);
|
||||
border-radius: 8px;
|
||||
background: rgba(255,255,255,0.018);
|
||||
overflow: hidden;
|
||||
}
|
||||
.repo-section + .repo-section { margin-top: 12px; }
|
||||
.repo-section > header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-height: 38px;
|
||||
padding: 0 12px;
|
||||
border-bottom: 1px solid var(--color-border-subtle);
|
||||
background: rgba(255,255,255,0.045);
|
||||
}
|
||||
.repo-section h2 {
|
||||
margin: 0;
|
||||
color: var(--color-ink);
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
}
|
||||
.repo-section > header span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 20px;
|
||||
min-height: 20px;
|
||||
border-radius: 999px;
|
||||
background: rgba(94, 110, 156, 0.18);
|
||||
color: var(--color-ink-dim);
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.repo-empty {
|
||||
padding: 20px 24px;
|
||||
color: var(--color-ink-faint);
|
||||
font-size: 13px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.repo-table {
|
||||
display: grid;
|
||||
}
|
||||
.repo-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: stretch;
|
||||
min-height: 36px;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.035);
|
||||
}
|
||||
.repo-row:last-child { border-bottom: 0; }
|
||||
.repo-row-main {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) minmax(160px, 360px);
|
||||
justify-content: stretch;
|
||||
min-height: 36px;
|
||||
padding: 0 10px 0 28px;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
}
|
||||
.repo-row-main:hover:not(:disabled) {
|
||||
background: rgba(90, 140, 248, 0.08);
|
||||
}
|
||||
.repo-row-name,
|
||||
.repo-row-path,
|
||||
.repo-row-meta {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--color-ink-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.repo-row-path {
|
||||
color: var(--color-ink-faint);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11.5px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.repo-row-meta {
|
||||
gap: 5px;
|
||||
justify-content: flex-start;
|
||||
color: var(--color-ink-dim);
|
||||
}
|
||||
.repo-row-meta strong,
|
||||
.repo-row-meta em {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-height: 20px;
|
||||
padding: 0 6px;
|
||||
border-radius: 4px;
|
||||
background: rgba(94, 110, 156, 0.18);
|
||||
color: var(--color-ink-dim);
|
||||
font-size: 10.5px;
|
||||
font-style: normal;
|
||||
font-weight: 800;
|
||||
}
|
||||
.repo-row-meta .ahead { color: #4eca76; }
|
||||
.repo-row-meta .behind { color: #e0a040; }
|
||||
.repo-row-icon {
|
||||
min-height: 36px;
|
||||
min-width: 36px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-left: 1px solid rgba(255,255,255,0.035);
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--color-ink-faint);
|
||||
}
|
||||
|
||||
/* --- Notices --- */
|
||||
|
||||
.notice {
|
||||
@@ -678,6 +953,22 @@
|
||||
|
||||
.file-row { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--color-border-subtle); border-radius: 8px; background: var(--color-surface-raised); }
|
||||
.file-row + .file-row { margin-top: 6px; }
|
||||
.file-row.selected { border-color: rgba(90,140,248,0.36); background: rgba(90,140,248,0.1); }
|
||||
|
||||
.file-title-button {
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
min-height: 24px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
text-align: left;
|
||||
}
|
||||
.file-title-button:hover:not(:disabled) {
|
||||
background: transparent;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.file-title strong {
|
||||
display: block;
|
||||
@@ -721,6 +1012,8 @@
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.branch-panel { position: relative; }
|
||||
|
||||
.branch-create-toggle {
|
||||
width: 26px;
|
||||
min-width: 26px;
|
||||
@@ -827,6 +1120,60 @@
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.branch-folder-row {
|
||||
display: grid;
|
||||
grid-template-columns: auto auto minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
justify-content: stretch;
|
||||
gap: 7px;
|
||||
width: 100%;
|
||||
min-height: 34px;
|
||||
padding: 5px 8px;
|
||||
padding-left: calc(8px + var(--branch-indent, 0px));
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: var(--color-ink-dim);
|
||||
text-align: left;
|
||||
}
|
||||
.branch-folder-row + .branch-folder-row,
|
||||
.branch-folder-row + .branch-row,
|
||||
.branch-row + .branch-folder-row {
|
||||
margin-top: 3px;
|
||||
}
|
||||
.branch-folder-row:hover:not(:disabled) {
|
||||
border-color: var(--color-border-subtle);
|
||||
background: var(--color-surface-hover);
|
||||
color: var(--color-ink);
|
||||
}
|
||||
.branch-folder-row.current {
|
||||
border-color: rgba(78,202,118,0.2);
|
||||
background: rgba(78,202,118,0.08);
|
||||
}
|
||||
.branch-folder-row svg { color: var(--color-ink-faint); }
|
||||
.branch-folder-row.current svg { color: #4eca76; }
|
||||
.branch-folder-name {
|
||||
overflow: hidden;
|
||||
color: var(--color-ink-muted);
|
||||
font-size: 12.5px;
|
||||
font-weight: 800;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.branch-folder-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 20px;
|
||||
min-height: 18px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
color: var(--color-ink-dim);
|
||||
background: rgba(94,110,156,0.14);
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.branch-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
@@ -834,6 +1181,7 @@
|
||||
gap: 8px;
|
||||
min-height: 46px;
|
||||
padding: 7px 8px;
|
||||
padding-left: calc(8px + var(--branch-indent, 0px));
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
transition: background 120ms, border-color 120ms;
|
||||
@@ -853,8 +1201,67 @@
|
||||
|
||||
.branch-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
|
||||
|
||||
.branch-context-menu,
|
||||
.explorer-context-menu {
|
||||
z-index: 120;
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
min-width: 184px;
|
||||
padding: 5px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
background: var(--color-surface-solid);
|
||||
box-shadow: 0 18px 50px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.branch-context-menu { position: absolute; }
|
||||
.explorer-context-menu { position: fixed; }
|
||||
|
||||
.branch-context-menu button,
|
||||
.explorer-context-menu button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-height: 30px;
|
||||
padding: 6px 8px;
|
||||
border-color: transparent;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--color-ink-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.branch-context-menu button:hover:not(:disabled),
|
||||
.explorer-context-menu button:hover:not(:disabled) {
|
||||
border-color: var(--color-border-subtle);
|
||||
background: rgba(255,255,255,0.06);
|
||||
color: var(--color-ink);
|
||||
}
|
||||
|
||||
.branch-context-menu button.danger {
|
||||
color: #ff9aa8;
|
||||
}
|
||||
|
||||
.branch-context-menu button.danger:hover:not(:disabled) {
|
||||
border-color: rgba(255,92,117,0.34);
|
||||
background: rgba(255,92,117,0.12);
|
||||
color: #ffd0d6;
|
||||
}
|
||||
|
||||
.branch-context-menu button:disabled,
|
||||
.explorer-context-menu button:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.48;
|
||||
}
|
||||
|
||||
/* --- Explorer --- */
|
||||
|
||||
.explorer-panel { position: relative; }
|
||||
|
||||
.explorer-head-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
|
||||
.explorer-bulk-button {
|
||||
width: 26px;
|
||||
@@ -998,6 +1405,82 @@
|
||||
.file-history-actions .commit-action-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; justify-content: stretch; }
|
||||
.file-history-actions .commit-action-buttons button { min-width: 0; justify-content: center; padding-inline: 6px; }
|
||||
|
||||
/* --- File history loading (scoped, non-blocking) --- */
|
||||
|
||||
.file-history-loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
min-height: 140px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.file-history-loading-graph { width: 56px; height: 56px; overflow: visible; }
|
||||
|
||||
.file-history-loading-graph .fhl-ring {
|
||||
fill: none;
|
||||
stroke: rgba(100, 108, 255, 0.22);
|
||||
stroke-width: 3;
|
||||
stroke-dasharray: 26 18;
|
||||
transform-origin: 60px 60px;
|
||||
animation: fhl-ring-spin 5s linear infinite;
|
||||
}
|
||||
|
||||
.file-history-loading-graph .fhl-trunk,
|
||||
.file-history-loading-graph .fhl-branch {
|
||||
fill: none;
|
||||
stroke: url(#fhl-line);
|
||||
stroke-width: 5;
|
||||
stroke-linecap: round;
|
||||
}
|
||||
|
||||
.file-history-loading-graph .fhl-branch {
|
||||
stroke-dasharray: 90;
|
||||
stroke-dashoffset: 90;
|
||||
animation: fhl-branch-draw 2.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.file-history-loading-graph .fhl-node {
|
||||
fill: var(--color-surface-alt);
|
||||
stroke: url(#fhl-line);
|
||||
stroke-width: 5;
|
||||
animation: fhl-node-pulse 2.4s ease-in-out infinite;
|
||||
}
|
||||
.file-history-loading-graph .fhl-n1 { animation-delay: 0s; }
|
||||
.file-history-loading-graph .fhl-n2 { animation-delay: 0.5s; }
|
||||
.file-history-loading-graph .fhl-n3 { animation-delay: 1s; }
|
||||
.file-history-loading-graph .fhl-n4 { animation-delay: 1.5s; }
|
||||
|
||||
.file-history-loading-label {
|
||||
color: var(--color-ink-faint);
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
@keyframes fhl-ring-spin { to { transform: rotate(360deg); } }
|
||||
@keyframes fhl-branch-draw {
|
||||
0% { stroke-dashoffset: 90; opacity: 0.35; }
|
||||
45% { stroke-dashoffset: 0; opacity: 1; }
|
||||
100% { stroke-dashoffset: 0; opacity: 1; }
|
||||
}
|
||||
@keyframes fhl-node-pulse {
|
||||
0%, 100% { fill: var(--color-surface-alt); filter: none; }
|
||||
50% {
|
||||
fill: var(--color-primary);
|
||||
filter: drop-shadow(0 0 6px rgba(100, 108, 255, 0.8));
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.file-history-loading-graph .fhl-ring,
|
||||
.file-history-loading-graph .fhl-branch,
|
||||
.file-history-loading-graph .fhl-node { animation: none; }
|
||||
.file-history-loading-graph .fhl-branch { stroke-dashoffset: 0; }
|
||||
}
|
||||
|
||||
/* --- Git graph --- */
|
||||
|
||||
.graph-list { padding: 0; }
|
||||
@@ -1113,12 +1596,25 @@
|
||||
max-height: calc(100vh - 32px);
|
||||
overflow: auto;
|
||||
}
|
||||
.rename-branch-dialog {
|
||||
display: block;
|
||||
width: min(520px, calc(100vw - 32px));
|
||||
height: auto;
|
||||
max-height: calc(100vh - 32px);
|
||||
overflow: auto;
|
||||
}
|
||||
.new-branch-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
}
|
||||
.rename-branch-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
}
|
||||
.new-branch-target {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -2380,6 +2876,12 @@
|
||||
.left-sidebar { grid-template-rows: minmax(200px, 1fr) minmax(240px, 1.2fr); min-height: 440px; }
|
||||
.top-section { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 190px; }
|
||||
.repo-form { grid-template-columns: 1fr; }
|
||||
.repo-tabbar { grid-template-columns: minmax(0, 1fr) auto; }
|
||||
.repo-tab.management { min-width: 0; }
|
||||
.repo-tabs-scroll { grid-column: 1 / -1; order: 2; border-top: 1px solid var(--color-border-subtle); }
|
||||
.repo-row-main { grid-template-columns: minmax(0, 1fr); gap: 2px; align-content: center; padding-left: 12px; }
|
||||
.repo-row { min-height: 58px; }
|
||||
.repo-row-icon { min-height: 58px; }
|
||||
.repo-path { display: none; }
|
||||
.repo-summary { height: 40px; }
|
||||
.change-lanes { grid-template-columns: 1fr; }
|
||||
|
||||
+19
-1
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import { getVersion } from "@tauri-apps/api/app";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { Download, GitBranch, GitCompare, LoaderCircle, Minus, RefreshCw, Search, Upload, X } from "@lucide/svelte";
|
||||
import { Download, FolderOpen, GitBranch, GitCompare, LoaderCircle, Minus, RefreshCw, Search, Upload, X } from "@lucide/svelte";
|
||||
|
||||
export let branch: string = "";
|
||||
export let ahead: number = 0;
|
||||
@@ -17,17 +18,20 @@
|
||||
export let onRefresh: () => void = () => {};
|
||||
export let onSearch: () => void = () => {};
|
||||
export let onCompare: () => void = () => {};
|
||||
export let onOpenInExplorer: () => void = () => {};
|
||||
export let onToggleAutoRefresh: () => void = () => {};
|
||||
|
||||
const win = getCurrentWindow();
|
||||
let isMaximized = false;
|
||||
let unlisten: (() => void) | undefined;
|
||||
let appVersion = "";
|
||||
|
||||
onMount(async () => {
|
||||
isMaximized = await win.isMaximized();
|
||||
unlisten = await win.onResized(async () => {
|
||||
isMaximized = await win.isMaximized();
|
||||
});
|
||||
appVersion = await getVersion();
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
@@ -57,6 +61,9 @@
|
||||
<line x1="12" y1="12" x2="12" y2="15" />
|
||||
</svg>
|
||||
<span data-tauri-drag-region>GitLite</span>
|
||||
{#if appVersion}
|
||||
<span class="tb-version" data-tauri-drag-region title="Version {appVersion}">v{appVersion}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Center: repo + branch info -->
|
||||
@@ -82,6 +89,17 @@
|
||||
<!-- Right: actions + window controls -->
|
||||
<div class="titlebar-right">
|
||||
<div class="titlebar-actions" role="toolbar" aria-label="Repository actions">
|
||||
<button
|
||||
class="tb-action"
|
||||
onclick={onOpenInExplorer}
|
||||
disabled={!hasRepository || isBusy}
|
||||
title="Open repository in Explorer"
|
||||
aria-label="Open repository in Explorer"
|
||||
>
|
||||
<FolderOpen size={14} aria-hidden="true" />
|
||||
<span class="tb-action-label">Explorer</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="tb-action"
|
||||
onclick={onSearch}
|
||||
|
||||
@@ -1,7 +1,46 @@
|
||||
<script lang="ts">
|
||||
import { Check, ChevronDown, ChevronRight, GitBranch, GitMerge, Plus, X } from "@lucide/svelte";
|
||||
import { Check, ChevronDown, ChevronRight, Folder, FolderOpen, GitBranch, GitMerge, Pencil, Plus, Trash2, X } from "@lucide/svelte";
|
||||
import type { GitBranch as GitBranchInfo } from "../types";
|
||||
|
||||
type BranchTreeNode = BranchFolderNode | BranchLeafNode;
|
||||
|
||||
interface BranchFolderNode {
|
||||
kind: "folder";
|
||||
id: string;
|
||||
name: string;
|
||||
children: BranchTreeNode[];
|
||||
branchCount: number;
|
||||
current: boolean;
|
||||
folders: Map<string, BranchFolderNode>;
|
||||
}
|
||||
|
||||
interface BranchLeafNode {
|
||||
kind: "branch";
|
||||
id: string;
|
||||
branch: GitBranchInfo;
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
type BranchRow = BranchFolderRow | BranchLeafRow;
|
||||
|
||||
interface BranchFolderRow {
|
||||
kind: "folder";
|
||||
id: string;
|
||||
name: string;
|
||||
depth: number;
|
||||
branchCount: number;
|
||||
current: boolean;
|
||||
}
|
||||
|
||||
interface BranchLeafRow {
|
||||
kind: "branch";
|
||||
id: string;
|
||||
branch: GitBranchInfo;
|
||||
displayName: string;
|
||||
depth: number;
|
||||
scopeLabel: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
branches: GitBranchInfo[];
|
||||
localBranches: GitBranchInfo[];
|
||||
@@ -11,6 +50,8 @@
|
||||
onCheckout: (branch: GitBranchInfo) => void;
|
||||
onMerge: (branch: GitBranchInfo) => void;
|
||||
onCreateBranch: (branchName: string) => void | Promise<void>;
|
||||
onRenameBranch: (branch: GitBranchInfo) => void | Promise<void>;
|
||||
onDeleteBranch: (branch: GitBranchInfo) => void | Promise<void>;
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -22,6 +63,8 @@
|
||||
onCheckout = () => {},
|
||||
onMerge = () => {},
|
||||
onCreateBranch = () => {},
|
||||
onRenameBranch = () => {},
|
||||
onDeleteBranch = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let localOpen = $state(true);
|
||||
@@ -29,6 +72,118 @@
|
||||
let createOpen = $state(false);
|
||||
let newBranchName = $state("");
|
||||
let createInput = $state<HTMLInputElement | null>(null);
|
||||
let panelElement = $state<HTMLElement | null>(null);
|
||||
let contextBranch = $state<GitBranchInfo | null>(null);
|
||||
let contextMenuX = $state(0);
|
||||
let contextMenuY = $state(0);
|
||||
let collapsedBranchFolders = $state<Set<string>>(new Set());
|
||||
|
||||
let localBranchRows = $derived(buildBranchRows("local", localBranches, "local"));
|
||||
let remoteBranchRows = $derived(buildBranchRows("remote", remoteBranches, "remote"));
|
||||
|
||||
function createFolder(id: string, name: string): BranchFolderNode {
|
||||
return {
|
||||
kind: "folder",
|
||||
id,
|
||||
name,
|
||||
children: [],
|
||||
branchCount: 0,
|
||||
current: false,
|
||||
folders: new Map(),
|
||||
};
|
||||
}
|
||||
|
||||
function buildBranchRows(scope: string, branchList: GitBranchInfo[], scopeLabel: string): BranchRow[] {
|
||||
const root = createFolder(`${scope}:root`, "");
|
||||
|
||||
for (const branch of branchList) {
|
||||
const parts = branch.name.split("/").filter(Boolean);
|
||||
const displayName = parts.length > 0 ? parts[parts.length - 1] : branch.name;
|
||||
const folderParts = parts.slice(0, -1);
|
||||
let parent = root;
|
||||
|
||||
for (let index = 0; index < folderParts.length; index += 1) {
|
||||
const folderName = folderParts[index];
|
||||
const folderPath = folderParts.slice(0, index + 1).join("/");
|
||||
let folder = parent.folders.get(folderName);
|
||||
|
||||
if (!folder) {
|
||||
folder = createFolder(`${scope}:folder:${folderPath}`, folderName);
|
||||
parent.folders.set(folderName, folder);
|
||||
parent.children.push(folder);
|
||||
}
|
||||
|
||||
folder.branchCount += 1;
|
||||
folder.current ||= branch.current;
|
||||
parent = folder;
|
||||
}
|
||||
|
||||
parent.children.push({
|
||||
kind: "branch",
|
||||
id: `${scope}:branch:${branch.name}`,
|
||||
branch,
|
||||
displayName,
|
||||
});
|
||||
}
|
||||
|
||||
sortBranchNodes(root.children);
|
||||
|
||||
const rows: BranchRow[] = [];
|
||||
flattenBranchNodes(root.children, rows, 0, scopeLabel);
|
||||
return rows;
|
||||
}
|
||||
|
||||
function sortBranchNodes(nodes: BranchTreeNode[]) {
|
||||
nodes.sort((left, right) => {
|
||||
if (left.kind !== right.kind) return left.kind === "folder" ? -1 : 1;
|
||||
const leftName = left.kind === "folder" ? left.name : left.displayName;
|
||||
const rightName = right.kind === "folder" ? right.name : right.displayName;
|
||||
return leftName.localeCompare(rightName, undefined, { sensitivity: "base" });
|
||||
});
|
||||
|
||||
for (const node of nodes) {
|
||||
if (node.kind === "folder") sortBranchNodes(node.children);
|
||||
}
|
||||
}
|
||||
|
||||
function flattenBranchNodes(nodes: BranchTreeNode[], rows: BranchRow[], depth: number, scopeLabel: string) {
|
||||
for (const node of nodes) {
|
||||
if (node.kind === "folder") {
|
||||
rows.push({
|
||||
kind: "folder",
|
||||
id: node.id,
|
||||
name: node.name,
|
||||
depth,
|
||||
branchCount: node.branchCount,
|
||||
current: node.current,
|
||||
});
|
||||
|
||||
if (isBranchFolderOpen(node.id)) {
|
||||
flattenBranchNodes(node.children, rows, depth + 1, scopeLabel);
|
||||
}
|
||||
} else {
|
||||
rows.push({
|
||||
kind: "branch",
|
||||
id: node.id,
|
||||
branch: node.branch,
|
||||
displayName: node.displayName,
|
||||
depth,
|
||||
scopeLabel,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isBranchFolderOpen(id: string) {
|
||||
return !collapsedBranchFolders.has(id);
|
||||
}
|
||||
|
||||
function toggleBranchFolder(id: string) {
|
||||
const next = new Set(collapsedBranchFolders);
|
||||
if (next.has(id)) next.delete(id);
|
||||
else next.add(id);
|
||||
collapsedBranchFolders = next;
|
||||
}
|
||||
|
||||
function openCreateForm() {
|
||||
if (!hasRepository || isBusy) return;
|
||||
@@ -57,9 +212,49 @@
|
||||
if (target?.closest("button")) return;
|
||||
onCheckout(branch);
|
||||
}
|
||||
|
||||
function openBranchContextMenu(event: MouseEvent, branch: GitBranchInfo) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (isBusy || branch.remote) return;
|
||||
|
||||
const rect = panelElement?.getBoundingClientRect();
|
||||
const rawX = rect ? event.clientX - rect.left : event.offsetX;
|
||||
const rawY = rect ? event.clientY - rect.top : event.offsetY;
|
||||
const maxX = Math.max(8, (rect?.width ?? window.innerWidth) - 192);
|
||||
const maxY = Math.max(8, (rect?.height ?? window.innerHeight) - 92);
|
||||
|
||||
contextBranch = branch;
|
||||
contextMenuX = Math.max(8, Math.min(rawX, maxX));
|
||||
contextMenuY = Math.max(8, Math.min(rawY, maxY));
|
||||
}
|
||||
|
||||
function closeBranchContextMenu() {
|
||||
contextBranch = null;
|
||||
}
|
||||
|
||||
async function renameContextBranch() {
|
||||
const branch = contextBranch;
|
||||
if (!branch || isBusy) return;
|
||||
closeBranchContextMenu();
|
||||
await onRenameBranch(branch);
|
||||
}
|
||||
|
||||
async function deleteContextBranch() {
|
||||
const branch = contextBranch;
|
||||
if (!branch || branch.current || isBusy) return;
|
||||
closeBranchContextMenu();
|
||||
await onDeleteBranch(branch);
|
||||
}
|
||||
|
||||
function handleWindowKeydown(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") closeBranchContextMenu();
|
||||
}
|
||||
</script>
|
||||
|
||||
<section class="panel grid grid-rows-[auto_1fr] overflow-hidden" aria-label="Branches">
|
||||
<svelte:window on:click={closeBranchContextMenu} on:keydown={handleWindowKeydown} on:contextmenu|capture={closeBranchContextMenu} />
|
||||
|
||||
<section bind:this={panelElement} class="panel branch-panel grid grid-rows-[auto_1fr] overflow-hidden" aria-label="Branches">
|
||||
<div class="section-head">
|
||||
<div>
|
||||
<span class="eyebrow">Branches</span>
|
||||
@@ -127,34 +322,58 @@
|
||||
{#if localBranches.length === 0}
|
||||
<div class="branch-empty">No local branches.</div>
|
||||
{:else}
|
||||
{#each localBranches as branch (branch.name)}
|
||||
<article
|
||||
class="branch-row"
|
||||
class:current={branch.current}
|
||||
ondblclick={(event) => checkoutOnDoubleClick(event, branch)}
|
||||
title={branch.current ? "Current branch" : "Double-click to checkout"}
|
||||
>
|
||||
<div class="branch-info">
|
||||
<GitBranch size={16} aria-hidden="true" />
|
||||
<div>
|
||||
<strong>{branch.name}</strong>
|
||||
<span>local</span>
|
||||
{#each localBranchRows as row (row.id)}
|
||||
{#if row.kind === "folder"}
|
||||
<button
|
||||
class="branch-folder-row"
|
||||
class:current={row.current}
|
||||
style={`--branch-indent: ${row.depth * 16}px;`}
|
||||
type="button"
|
||||
onclick={() => toggleBranchFolder(row.id)}
|
||||
aria-expanded={isBranchFolderOpen(row.id)}
|
||||
title={`${row.name} (${row.branchCount})`}
|
||||
>
|
||||
{#if isBranchFolderOpen(row.id)}
|
||||
<ChevronDown size={14} aria-hidden="true" />
|
||||
<FolderOpen size={15} aria-hidden="true" />
|
||||
{:else}
|
||||
<ChevronRight size={14} aria-hidden="true" />
|
||||
<Folder size={15} aria-hidden="true" />
|
||||
{/if}
|
||||
<span class="branch-folder-name">{row.name}</span>
|
||||
<span class="branch-folder-count">{row.branchCount}</span>
|
||||
</button>
|
||||
{:else}
|
||||
<article
|
||||
class="branch-row"
|
||||
class:current={row.branch.current}
|
||||
style={`--branch-indent: ${row.depth * 16}px;`}
|
||||
ondblclick={(event) => checkoutOnDoubleClick(event, row.branch)}
|
||||
oncontextmenu={(event) => openBranchContextMenu(event, row.branch)}
|
||||
title={row.branch.current ? "Current branch" : row.branch.name}
|
||||
>
|
||||
<div class="branch-info">
|
||||
<GitBranch size={16} aria-hidden="true" />
|
||||
<div>
|
||||
<strong>{row.displayName}</strong>
|
||||
<span>{row.scopeLabel}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if branch.current}
|
||||
<span class="pill pill-active">Current</span>
|
||||
{:else}
|
||||
<div class="branch-actions">
|
||||
<button class="btn-sm" type="button" onclick={() => onCheckout(branch)} disabled={isBusy}>
|
||||
Checkout
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onMerge(branch)} disabled={isBusy} title="Merge into current">
|
||||
<GitMerge size={15} aria-hidden="true" />
|
||||
Merge
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</article>
|
||||
{#if row.branch.current}
|
||||
<span class="pill pill-active">Current</span>
|
||||
{:else}
|
||||
<div class="branch-actions">
|
||||
<button class="btn-sm" type="button" onclick={() => onCheckout(row.branch)} disabled={isBusy}>
|
||||
Checkout
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onMerge(row.branch)} disabled={isBusy} title="Merge into current">
|
||||
<GitMerge size={15} aria-hidden="true" />
|
||||
Merge
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</article>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
@@ -180,38 +399,87 @@
|
||||
{#if remoteBranches.length === 0}
|
||||
<div class="branch-empty">No remote branches.</div>
|
||||
{:else}
|
||||
{#each remoteBranches as branch (branch.name)}
|
||||
<article
|
||||
class="branch-row"
|
||||
class:current={branch.current}
|
||||
ondblclick={(event) => checkoutOnDoubleClick(event, branch)}
|
||||
title={branch.current ? "Current branch" : "Double-click to checkout"}
|
||||
>
|
||||
<div class="branch-info">
|
||||
<GitBranch size={16} aria-hidden="true" />
|
||||
<div>
|
||||
<strong>{branch.name}</strong>
|
||||
<span>remote</span>
|
||||
{#each remoteBranchRows as row (row.id)}
|
||||
{#if row.kind === "folder"}
|
||||
<button
|
||||
class="branch-folder-row"
|
||||
class:current={row.current}
|
||||
style={`--branch-indent: ${row.depth * 16}px;`}
|
||||
type="button"
|
||||
onclick={() => toggleBranchFolder(row.id)}
|
||||
aria-expanded={isBranchFolderOpen(row.id)}
|
||||
title={`${row.name} (${row.branchCount})`}
|
||||
>
|
||||
{#if isBranchFolderOpen(row.id)}
|
||||
<ChevronDown size={14} aria-hidden="true" />
|
||||
<FolderOpen size={15} aria-hidden="true" />
|
||||
{:else}
|
||||
<ChevronRight size={14} aria-hidden="true" />
|
||||
<Folder size={15} aria-hidden="true" />
|
||||
{/if}
|
||||
<span class="branch-folder-name">{row.name}</span>
|
||||
<span class="branch-folder-count">{row.branchCount}</span>
|
||||
</button>
|
||||
{:else}
|
||||
<article
|
||||
class="branch-row"
|
||||
class:current={row.branch.current}
|
||||
style={`--branch-indent: ${row.depth * 16}px;`}
|
||||
ondblclick={(event) => checkoutOnDoubleClick(event, row.branch)}
|
||||
title={row.branch.current ? "Current branch" : row.branch.name}
|
||||
>
|
||||
<div class="branch-info">
|
||||
<GitBranch size={16} aria-hidden="true" />
|
||||
<div>
|
||||
<strong>{row.displayName}</strong>
|
||||
<span>{row.scopeLabel}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if branch.current}
|
||||
<span class="pill pill-active">Current</span>
|
||||
{:else}
|
||||
<div class="branch-actions">
|
||||
<button class="btn-sm" type="button" onclick={() => onCheckout(branch)} disabled={isBusy}>
|
||||
Checkout
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onMerge(branch)} disabled={isBusy} title="Merge into current">
|
||||
<GitMerge size={15} aria-hidden="true" />
|
||||
Merge
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</article>
|
||||
{#if row.branch.current}
|
||||
<span class="pill pill-active">Current</span>
|
||||
{:else}
|
||||
<div class="branch-actions">
|
||||
<button class="btn-sm" type="button" onclick={() => onCheckout(row.branch)} disabled={isBusy}>
|
||||
Checkout
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onMerge(row.branch)} disabled={isBusy} title="Merge into current">
|
||||
<GitMerge size={15} aria-hidden="true" />
|
||||
Merge
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</article>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if contextBranch}
|
||||
<div
|
||||
class="branch-context-menu"
|
||||
style={`left: ${contextMenuX}px; top: ${contextMenuY}px;`}
|
||||
role="menu"
|
||||
tabindex="-1"
|
||||
aria-label={`Actions for ${contextBranch.name}`}
|
||||
>
|
||||
<button type="button" role="menuitem" onclick={renameContextBranch} disabled={isBusy}>
|
||||
<Pencil size={14} aria-hidden="true" />
|
||||
Rename
|
||||
</button>
|
||||
<button
|
||||
class="danger"
|
||||
type="button"
|
||||
role="menuitem"
|
||||
onclick={deleteContextBranch}
|
||||
disabled={isBusy || contextBranch.current}
|
||||
title={contextBranch.current ? "Current branch cannot be deleted" : "Delete local branch"}
|
||||
>
|
||||
<Trash2 size={14} aria-hidden="true" />
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
FileVideo,
|
||||
Folder,
|
||||
FolderOpen,
|
||||
ExternalLink,
|
||||
Terminal,
|
||||
} from "@lucide/svelte";
|
||||
import { languageIconForPath } from "../languageIcons";
|
||||
@@ -34,6 +35,7 @@
|
||||
onExpandAllFolders: () => void;
|
||||
onCollapseAllFolders: () => void;
|
||||
onSelectNode: (node: ExplorerNode) => void;
|
||||
onOpenFile: (node: ExplorerNode) => void;
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -47,8 +49,13 @@
|
||||
onExpandAllFolders = () => {},
|
||||
onCollapseAllFolders = () => {},
|
||||
onSelectNode = () => {},
|
||||
onOpenFile = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let contextNode = $state<ExplorerNode | null>(null);
|
||||
let contextMenuX = $state(0);
|
||||
let contextMenuY = $state(0);
|
||||
|
||||
function mergeExplorerStatus(current: FileStatusKind | null, next: FileStatusKind | null): FileStatusKind | null {
|
||||
if (!next) return current;
|
||||
if (!current) return next;
|
||||
@@ -154,12 +161,39 @@
|
||||
return "text";
|
||||
}
|
||||
|
||||
function openFileContextMenu(event: MouseEvent, node: ExplorerNode) {
|
||||
if (node.kind !== "file") return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
contextNode = node;
|
||||
contextMenuX = Math.max(8, Math.min(event.clientX + 2, window.innerWidth - 192));
|
||||
contextMenuY = Math.max(8, Math.min(event.clientY + 2, window.innerHeight - 56));
|
||||
}
|
||||
|
||||
function closeFileContextMenu() {
|
||||
contextNode = null;
|
||||
}
|
||||
|
||||
function openContextFile() {
|
||||
const node = contextNode;
|
||||
if (!node || node.kind !== "file") return;
|
||||
closeFileContextMenu();
|
||||
onOpenFile(node);
|
||||
}
|
||||
|
||||
function handleWindowKeydown(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") closeFileContextMenu();
|
||||
}
|
||||
|
||||
let explorerTree = $derived(buildExplorerTree(repoFiles));
|
||||
let visibleNodes = $derived(flattenExplorerTree(explorerTree, expandedExplorerPaths));
|
||||
let hasFolders = $derived(explorerTree.some((node) => node.kind === "folder"));
|
||||
</script>
|
||||
|
||||
<section class="panel grid grid-rows-[auto_1fr] overflow-hidden" aria-label="File explorer">
|
||||
<svelte:window on:click={closeFileContextMenu} on:keydown={handleWindowKeydown} on:contextmenu|capture={closeFileContextMenu} />
|
||||
|
||||
<section class="panel explorer-panel grid grid-rows-[auto_1fr] overflow-hidden" aria-label="File explorer">
|
||||
<div class="section-head">
|
||||
<div>
|
||||
<span class="eyebrow">Explorer</span>
|
||||
@@ -264,6 +298,7 @@
|
||||
class="explorer-select"
|
||||
type="button"
|
||||
onclick={() => onSelectNode(node)}
|
||||
oncontextmenu={(event) => openFileContextMenu(event, node)}
|
||||
disabled={isBusy}
|
||||
title={`Show history for ${node.path}`}
|
||||
>
|
||||
@@ -279,4 +314,26 @@
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</section>
|
||||
|
||||
{#if contextNode}
|
||||
<div
|
||||
class="explorer-context-menu"
|
||||
style={`left: ${contextMenuX}px; top: ${contextMenuY}px;`}
|
||||
role="menu"
|
||||
tabindex="-1"
|
||||
aria-label={`Actions for ${contextNode.path}`}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
onclick={openContextFile}
|
||||
disabled={contextNode.status === "deleted"}
|
||||
title={contextNode.status === "deleted" ? "Deleted files cannot be revealed in Explorer" : "Reveal this file in Explorer"}
|
||||
>
|
||||
<ExternalLink size={14} aria-hidden="true" />
|
||||
Open in Explorer
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
selectedExplorerLabel: string;
|
||||
hasRepository: boolean;
|
||||
isBusy: boolean;
|
||||
isLoading?: boolean;
|
||||
onDiff: (commit: GitCommit) => void;
|
||||
onRestore: (commit: GitCommit) => void;
|
||||
}
|
||||
@@ -18,6 +19,7 @@
|
||||
selectedExplorerLabel = "File history",
|
||||
hasRepository = false,
|
||||
isBusy = false,
|
||||
isLoading = false,
|
||||
onDiff = () => {},
|
||||
onRestore = () => {},
|
||||
}: Props = $props();
|
||||
@@ -89,6 +91,25 @@
|
||||
<div class="blank-state">No repository loaded.</div>
|
||||
{:else if !selectedExplorerPath}
|
||||
<div class="blank-state">Select a file in Explorer.</div>
|
||||
{:else if isLoading}
|
||||
<div class="file-history-loading" role="status" aria-live="polite">
|
||||
<svg class="file-history-loading-graph" viewBox="0 0 120 120" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="fhl-line" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#646cff" />
|
||||
<stop offset="100%" stop-color="#41d1ff" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<circle class="fhl-ring" cx="60" cy="60" r="52" />
|
||||
<path class="fhl-trunk" d="M42 22 L42 98" />
|
||||
<path class="fhl-branch" d="M42 44 C42 62, 82 58, 82 76 L82 88" />
|
||||
<circle class="fhl-node fhl-n1" cx="42" cy="30" r="6" />
|
||||
<circle class="fhl-node fhl-n2" cx="42" cy="60" r="6" />
|
||||
<circle class="fhl-node fhl-n3" cx="82" cy="88" r="6" />
|
||||
<circle class="fhl-node fhl-n4" cx="42" cy="90" r="6" />
|
||||
</svg>
|
||||
<span class="file-history-loading-label">Loading history…</span>
|
||||
</div>
|
||||
{:else if fileHistory.length === 0}
|
||||
<div class="blank-state">No history returned for this selection.</div>
|
||||
{:else}
|
||||
|
||||
@@ -226,7 +226,7 @@
|
||||
<GitBranch size={15} aria-hidden="true" />
|
||||
Branch
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onRestoreCommit(item)} disabled={isBusy} title="Reset current branch to this commit">
|
||||
<button class="btn-sm" type="button" onclick={() => onRestoreCommit(item)} disabled={isBusy} title="Bring this commit's files into your working tree as unstaged changes (no history is changed)">
|
||||
<RotateCcw size={15} aria-hidden="true" />
|
||||
Restore
|
||||
</button>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<script lang="ts">
|
||||
import { GitBranch, LoaderCircle, X } from "@lucide/svelte";
|
||||
import type { GitBranch as GitBranchInfo } from "../types";
|
||||
|
||||
interface Props {
|
||||
branch: GitBranchInfo;
|
||||
isBusy: boolean;
|
||||
onRename: (name: string) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
let {
|
||||
branch,
|
||||
isBusy = false,
|
||||
onRename = () => {},
|
||||
onClose = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let name = $state("");
|
||||
|
||||
$effect(() => {
|
||||
name = branch.name;
|
||||
});
|
||||
|
||||
function submit(event: SubmitEvent) {
|
||||
event.preventDefault();
|
||||
const value = name.trim();
|
||||
if (!value || value === branch.name) return;
|
||||
onRename(value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="dialog-backdrop"
|
||||
role="presentation"
|
||||
onclick={(e) => { if (e.target === e.currentTarget) onClose(); }}
|
||||
>
|
||||
<div class="dialog rename-branch-dialog" role="dialog" aria-modal="true" aria-label="Rename branch" tabindex="-1">
|
||||
<header class="dialog-header">
|
||||
<div>
|
||||
<span class="eyebrow">Rename branch</span>
|
||||
<h2 class="mt-0.5 text-ink text-base font-bold leading-tight">{branch.name}</h2>
|
||||
</div>
|
||||
<button class="dialog-close" type="button" onclick={onClose} title="Close">
|
||||
<X size={18} aria-hidden="true" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<form class="rename-branch-form" onsubmit={submit}>
|
||||
<label class="new-branch-field">
|
||||
<span>Branch name</span>
|
||||
<!-- svelte-ignore a11y_autofocus -->
|
||||
<input
|
||||
bind:value={name}
|
||||
autocomplete="off"
|
||||
spellcheck="false"
|
||||
disabled={isBusy}
|
||||
autofocus
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div class="new-branch-actions">
|
||||
<button class="btn-secondary" type="button" onclick={onClose} disabled={isBusy}>
|
||||
Cancel
|
||||
</button>
|
||||
<button class="btn-primary" type="submit" disabled={isBusy || name.trim().length === 0 || name.trim() === branch.name}>
|
||||
{#if isBusy}
|
||||
<LoaderCircle class="spin" size={16} aria-hidden="true" />
|
||||
{:else}
|
||||
<GitBranch size={16} aria-hidden="true" />
|
||||
{/if}
|
||||
Rename
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -9,6 +9,8 @@
|
||||
hasRepository: boolean;
|
||||
isBusy: boolean;
|
||||
status: GitStatus | null;
|
||||
selectedFilePath: string;
|
||||
onSelectFile: (file: GitFileStatus) => void;
|
||||
onStage: (file: GitFileStatus) => void;
|
||||
onUnstage: (file: GitFileStatus) => void;
|
||||
onDiscard: (file: GitFileStatus, staged: boolean) => void;
|
||||
@@ -24,6 +26,8 @@
|
||||
hasRepository = false,
|
||||
isBusy = false,
|
||||
status = null,
|
||||
selectedFilePath = "",
|
||||
onSelectFile = () => {},
|
||||
onStage = () => {},
|
||||
onUnstage = () => {},
|
||||
onDiscard = () => {},
|
||||
@@ -102,9 +106,19 @@
|
||||
{:else}
|
||||
<div class="overflow-auto p-2">
|
||||
{#each changedFiles as file (`${file.old_path ?? ""}:${file.path}`)}
|
||||
<article class="file-row">
|
||||
<article
|
||||
class="file-row"
|
||||
class:selected={selectedFilePath === file.path}
|
||||
>
|
||||
<div class="file-title">
|
||||
<strong title={displayPath(file)}>{fileName(file)}</strong>
|
||||
<button
|
||||
class="file-title-button"
|
||||
type="button"
|
||||
onclick={() => onSelectFile(file)}
|
||||
title={`Select ${displayPath(file)} in Explorer`}
|
||||
>
|
||||
<strong>{fileName(file)}</strong>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="change-lanes">
|
||||
@@ -121,7 +135,7 @@
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onPatch(file, true)} disabled={isBusy || !canPatch(file.staged)} title="Stage, unstage, or discard selected lines">
|
||||
<FileDiff size={14} aria-hidden="true" />
|
||||
Lines
|
||||
Details
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onDiscard(file, true)} disabled={isBusy} title="Discard staged changes">
|
||||
<RotateCcw size={14} aria-hidden="true" />
|
||||
@@ -146,7 +160,7 @@
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onPatch(file, false)} disabled={isBusy || !canPatch(file.unstaged)} title="Stage or discard selected lines">
|
||||
<FileDiff size={14} aria-hidden="true" />
|
||||
Lines
|
||||
Details
|
||||
</button>
|
||||
<button class="btn-sm" type="button" onclick={() => onDiscard(file, false)} disabled={isBusy} title="Discard unstaged changes">
|
||||
<RotateCcw size={14} aria-hidden="true" />
|
||||
|
||||
+31
-2
@@ -17,6 +17,14 @@ export function openRepository(path: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("open_repository", { path });
|
||||
}
|
||||
|
||||
export function openRepoInExplorer(path: string): Promise<void> {
|
||||
return invoke<void>("open_repo_in_explorer", { path });
|
||||
}
|
||||
|
||||
export function openRepositoryFile(path: string, file: string): Promise<void> {
|
||||
return invoke<void>("open_repository_file", { path, file });
|
||||
}
|
||||
|
||||
export function openRepositoryBundle(path: string, commitLimit = 100): Promise<RepositoryBundle> {
|
||||
return invoke<RepositoryBundle>("open_repository_bundle", { path, commitLimit });
|
||||
}
|
||||
@@ -41,6 +49,18 @@ export function createBranch(
|
||||
return invoke<GitStatus>("create_branch", { path, branch, startPoint: startPoint ?? null });
|
||||
}
|
||||
|
||||
export function renameBranch(
|
||||
path: string,
|
||||
oldBranch: string,
|
||||
newBranch: string,
|
||||
): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("rename_branch", { path, oldBranch, newBranch });
|
||||
}
|
||||
|
||||
export function deleteBranch(path: string, branch: string): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("delete_branch", { path, branch });
|
||||
}
|
||||
|
||||
export function stageFiles(path: string, files: string[]): Promise<GitStatus> {
|
||||
return invoke<GitStatus>("stage_files", { path, files });
|
||||
}
|
||||
@@ -127,8 +147,17 @@ export function listRepositoryFiles(path: string): Promise<GitRepositoryFile[]>
|
||||
return invoke<GitRepositoryFile[]>("list_repository_files", { path });
|
||||
}
|
||||
|
||||
export function listFileHistory(path: string, file: string, limit = 100): Promise<GitCommit[]> {
|
||||
return invoke<GitCommit[]>("list_file_history", { path, file, limit });
|
||||
export function listFileHistory(
|
||||
path: string,
|
||||
file: string,
|
||||
limit = 100,
|
||||
requestId?: string,
|
||||
): Promise<GitCommit[]> {
|
||||
return invoke<GitCommit[]>("list_file_history", { path, file, limit, requestId: requestId ?? null });
|
||||
}
|
||||
|
||||
export function cancelFileHistory(requestId: string): Promise<void> {
|
||||
return invoke<void>("cancel_file_history", { requestId });
|
||||
}
|
||||
|
||||
export function compareCommits(
|
||||
|
||||
Reference in New Issue
Block a user