Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ struct GitStatusEntry {
path: String,
}

#[derive(serde::Serialize)]
struct BranchInfo {
name: String,
is_current: bool,
}

#[tauri::command]
fn git_status(path: String) -> Result<Vec<GitStatusEntry>, String> {
let output = new_command("git")
Expand Down Expand Up @@ -475,6 +481,48 @@ fn get_git_branch(path: String) -> Result<String, String> {
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
}

#[tauri::command]
fn git_list_branches(repo_path: String) -> Result<Vec<BranchInfo>, String> {
let dir = std::path::Path::new(&repo_path);
let out = run_git(dir, &["branch"])?;
if !out.status.success() {
return Err(git_stderr(&out));
}
let branches = String::from_utf8_lossy(&out.stdout)
.lines()
.filter(|l| l.len() >= 2)
.map(|l| {
let is_current = l.starts_with("* ");
let name = l[2..].trim().to_string();
BranchInfo { name, is_current }
})
.filter(|b| !b.name.is_empty())
.collect();
Ok(branches)
}

#[tauri::command]
fn git_switch_branch(repo_path: String, branch: String) -> Result<(), String> {
let dir = std::path::Path::new(&repo_path);
let out = run_git(dir, &["checkout", &branch])?;
if out.status.success() { Ok(()) } else { Err(git_stderr(&out)) }
}

#[tauri::command]
fn git_delete_branch(repo_path: String, branch: String, force: bool, delete_remote: bool) -> Result<(), String> {
let dir = std::path::Path::new(&repo_path);
let flag = if force { "-D" } else { "-d" };
let local = run_git(dir, &["branch", flag, &branch])?;
if !local.status.success() {
return Err(git_stderr(&local));
}
if delete_remote {
// Best-effort — don't fail if the remote branch doesn't exist
let _ = run_git(dir, &["push", "origin", "--delete", &branch]);
}
Ok(())
}

#[tauri::command]
fn git_worktree_remove(repo_path: String, worktree_path: String) -> Result<(), String> {
#[cfg(windows)]
Expand Down Expand Up @@ -1465,6 +1513,9 @@ pub fn run() {
git_push_branch,
git_push_current_branch,
git_create_push_branch,
git_list_branches,
git_switch_branch,
git_delete_branch,
git_stage,
git_unstage,
git_discard,
Expand Down
149 changes: 149 additions & 0 deletions src/components/DiffPane.css
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,155 @@
.dp-branch-input:focus { border-color: var(--tempest-accent-blue); }
.dp-branch-input::placeholder { color: var(--tempest-fg-subtle); opacity: 0.6; }

/* ── Branch picker ──────────────────────────────────────────────────────────── */

.dp-branch-picker {
position: relative;
flex-shrink: 0;
}

.dp-branch-pill {
display: flex;
align-items: center;
gap: 5px;
padding: 4px 8px;
border: 1px solid var(--tempest-border-subtle);
border-radius: 5px;
background: var(--tempest-bg-active);
color: var(--tempest-fg-muted);
font-size: 11px;
font-family: "Geist Mono", monospace;
cursor: pointer;
white-space: nowrap;
transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
max-width: 160px;
}

.dp-branch-pill:hover {
background: var(--tempest-bg-hover);
color: var(--tempest-fg-default);
border-color: var(--tempest-border-default);
}

.dp-branch-pill-name {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
}

.dp-chevron--open {
transform: rotate(180deg);
transition: transform 0.15s ease;
}

.dp-branch-menu {
position: absolute;
top: calc(100% + 6px);
left: 0;
min-width: 200px;
background: var(--tempest-bg-panel);
border: 1px solid var(--tempest-border-default);
border-radius: 7px;
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
z-index: 100;
overflow: hidden;
padding: 4px 0;
}

.dp-branch-menu-empty {
padding: 8px 12px;
font-size: 11px;
color: var(--tempest-fg-subtle);
opacity: 0.6;
}

.dp-branch-menu-row {
display: flex;
align-items: center;
gap: 4px;
padding: 0 6px 0 8px;
height: 30px;
transition: background 0.1s ease;
}

.dp-branch-menu-row:hover { background: var(--tempest-bg-hover); }

.dp-branch-menu-row--current { background: var(--tempest-bg-active); }
.dp-branch-menu-row--current:hover { background: var(--tempest-bg-active); }

.dp-branch-menu-check {
flex-shrink: 0;
width: 16px;
color: var(--tempest-accent-blue);
display: flex;
align-items: center;
}

.dp-branch-menu-name {
flex: 1;
background: none;
border: none;
padding: 0;
text-align: left;
font-size: 12px;
font-family: "Geist Mono", monospace;
color: var(--tempest-fg-muted);
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
}

.dp-branch-menu-row--current .dp-branch-menu-name {
color: var(--tempest-fg-default);
font-weight: 500;
cursor: default;
}

.dp-branch-menu-name:hover:not(:disabled) { color: var(--tempest-fg-default); }

.dp-branch-menu-del {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
border: none;
border-radius: 4px;
background: transparent;
color: var(--tempest-fg-subtle);
cursor: pointer;
opacity: 0;
transition: opacity 0.1s ease, background 0.1s ease, color 0.1s ease;
}

.dp-branch-menu-row:hover .dp-branch-menu-del { opacity: 1; }
.dp-branch-menu-del:hover { background: var(--tempest-git-deleted); color: #fff; }

/* ── Delete branch dialog extras ─────────────────────────────────────────────── */

.dp-dialog-icon--delete { color: var(--tempest-git-deleted); }

.dp-dialog-warn--error {
color: var(--tempest-git-deleted);
font-size: 11px;
text-align: center;
max-width: 240px;
word-break: break-word;
}

.dp-delete-remote-row {
display: flex;
align-items: center;
gap: 8px;
cursor: pointer;
padding: 2px 0;
}

.dp-push-error {
flex-shrink: 0;
padding: 6px 12px;
Expand Down
Loading
Loading