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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ npm run tauri build
Rust commands live in `src-tauri/src/commands`, shared services in `src-tauri/src/services`, and serialized models in `src-tauri/src/models`. The backend uses native Git CLI through `std::process::Command` with argument arrays; shell strings are not used for Git operations.

React UI lives in `src/components`, state in `src/store/gitStore.ts`, IPC services in `src/services/gitService.ts`, and shared TypeScript types in `src/types/git.ts`.

## GitPilot feature coverage

GitPilot now includes first-pass production workflows for the highest-priority Git operations:

- Visual conflict resolution parses conflict markers, presents current/incoming/result panes, supports accept-current, accept-incoming, accept-both, manual edits, and stages files after all markers are removed.
- Rebase tooling supports normal rebase, paused-state detection, continue, abort, skip, and an interactive todo editor for pick, reword, edit, squash, fixup, drop, and reorder operations.
- Cherry-pick commands support applying a selected commit and aborting an in-progress cherry-pick so conflicts can route through the same resolver.
- Stash management supports list, push, apply, pop, drop, and rename from the stash panel.
- Productivity primitives are available for blame, fuzzy smart search, and worktree list/create/remove commands.

Some larger roadmap items, such as provider-backed pull-request review, CI aggregation, enterprise telemetry, and release signing, are intentionally exposed as modular command/service seams for follow-up hardening rather than hard-coded into the UI.
40 changes: 40 additions & 0 deletions src-tauri/src/commands/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,43 @@ pub fn reset_to_commit(
};
git_service::git_checked(&repo_path, &["reset", flag, &commit])
}

#[tauri::command]
pub fn abort_cherry_pick(
repo_path: String,
) -> Result<crate::models::git::GitCommandOutput, GitError> {
git_service::git_checked(&repo_path, &["cherry-pick", "--abort"])
}

#[tauri::command]
pub fn blame_file(
repo_path: String,
file_path: String,
) -> Result<Vec<crate::models::git::BlameLine>, GitError> {
let out = git_service::git_text(&repo_path, &["blame", "--line-porcelain", "--", &file_path])?;
let mut res = Vec::new();
let mut commit = String::new();
let mut author = String::new();
let mut time = String::new();
let mut line_no = 0usize;
for l in out.lines() {
if l.chars().take(40).all(|c| c.is_ascii_hexdigit()) {
let p: Vec<_> = l.split_whitespace().collect();
commit = p[0].into();
line_no = p.get(2).and_then(|v| v.parse().ok()).unwrap_or(0);
} else if let Some(v) = l.strip_prefix("author ") {
author = v.into();
} else if let Some(v) = l.strip_prefix("author-time ") {
time = v.into();
} else if let Some(v) = l.strip_prefix('\t') {
res.push(crate::models::git::BlameLine {
line_number: line_no,
commit: commit.clone(),
author: author.clone(),
timestamp: time.clone(),
text: v.into(),
});
}
}
Ok(res)
}
2 changes: 2 additions & 0 deletions src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ pub mod merge;
pub mod rebase;
pub mod remote;
pub mod repository;
pub mod search;
pub mod settings;
pub mod staging;
pub mod stash;
pub mod status;
pub mod tag;
pub mod validation;
pub mod worktree;
101 changes: 101 additions & 0 deletions src-tauri/src/commands/rebase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,104 @@ pub fn abort_rebase(repo_path: String) -> Result<GitCommandOutput, GitError> {
pub fn skip_rebase(repo_path: String) -> Result<GitCommandOutput, GitError> {
git_service::git_checked(&repo_path, &["rebase", "--skip"])
}

use crate::models::git::{RebaseState, RebaseTodoItem};
use std::{fs, path::Path};

#[tauri::command]
pub fn get_rebase_state(repo_path: String) -> Result<RebaseState, GitError> {
let git = Path::new(&repo_path).join(".git");
let merge = git.join("rebase-merge");
let apply = git.join("rebase-apply");
let dir = if merge.exists() { merge } else { apply };
if !dir.exists() {
return Ok(RebaseState {
in_progress: false,
interactive: false,
current_branch: None,
onto: None,
todo: vec![],
});
}
let todo_path = dir.join("git-rebase-todo");
let done_path = dir.join("done");
let todo_src = fs::read_to_string(&todo_path)
.or_else(|_| fs::read_to_string(&done_path))
.unwrap_or_default();
let todo = todo_src
.lines()
.filter_map(|l| {
let line = l.trim();
if line.is_empty() || line.starts_with('#') {
return None;
}
let mut p = line.splitn(3, ' ');
Some(RebaseTodoItem {
action: p.next()?.into(),
hash: p.next().unwrap_or_default().into(),
message: p.next().unwrap_or_default().into(),
})
})
.collect();
Ok(RebaseState {
in_progress: true,
interactive: todo_path.exists(),
current_branch: fs::read_to_string(dir.join("head-name"))
.ok()
.map(|s| s.trim().trim_start_matches("refs/heads/").into()),
onto: fs::read_to_string(dir.join("onto"))
.ok()
.map(|s| s.trim().into()),
todo,
})
}

#[tauri::command]
pub fn start_interactive_rebase(
repo_path: String,
base: String,
todo: Vec<RebaseTodoItem>,
) -> Result<GitCommandOutput, GitError> {
let script = todo
.into_iter()
.map(|i| format!("{} {} {}", i.action, i.hash, i.message))
.collect::<Vec<_>>()
.join("\n");
let dir = std::env::temp_dir();
let todo_path = dir.join("gitpilot-rebase-todo.txt");
fs::write(&todo_path, script)
.map_err(|e| GitError::new("TODO_WRITE_FAILED", e.to_string(), ""))?;
let editor_path = if cfg!(windows) {
let path = dir.join("gitpilot-sequence-editor.cmd");
fs::write(
&path,
format!("@echo off\r\ntype \"{}\" > %1\r\n", todo_path.display()),
)
.map_err(|e| GitError::new("EDITOR_WRITE_FAILED", e.to_string(), ""))?;
path
} else {
let path = dir.join("gitpilot-sequence-editor.sh");
fs::write(
&path,
format!("#!/bin/sh\ncat '{}' > \"$1\"\n", todo_path.display()),
)
.map_err(|e| GitError::new("EDITOR_WRITE_FAILED", e.to_string(), ""))?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
let mut perms = fs::metadata(&path)
.map_err(|e| GitError::new("EDITOR_STAT_FAILED", e.to_string(), ""))?
.permissions();
perms.set_mode(0o700);
fs::set_permissions(&path, perms)
.map_err(|e| GitError::new("EDITOR_CHMOD_FAILED", e.to_string(), ""))?;
}
path
};
let editor = editor_path.to_string_lossy().to_string();
git_service::git_checked_env(
&repo_path,
&["rebase", "-i", &base],
&[(&"GIT_SEQUENCE_EDITOR", &editor)],
)
}
71 changes: 71 additions & 0 deletions src-tauri/src/commands/search.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
use crate::{
models::git::{GitError, SearchResult},
services::git_service,
};

fn matches(q: &str, text: &str) -> bool {
let q = q.to_lowercase();
let text = text.to_lowercase();
let mut it = text.chars();
q.chars().all(|c| it.any(|x| x == c))
}
#[tauri::command]
pub fn smart_search(
repo_path: String,
query: String,
limit: u32,
) -> Result<Vec<SearchResult>, GitError> {
let mut r = Vec::new();
let lim = limit.to_string();
let commits = git_service::git_text(
&repo_path,
&[
"log",
"--all",
"--date=short",
&format!("--max-count={}", lim),
"--pretty=format:%h%x1f%an%x1f%ad%x1f%s",
],
)?;
for l in commits.lines() {
let p: Vec<_> = l.split('\x1f').collect();
if p.len() == 4 {
let hay = format!("{} {} {}", p[0], p[1], p[3]);
if matches(&query, &hay) {
r.push(SearchResult {
kind: "commit".into(),
title: p[3].into(),
subtitle: format!("{} · {} · {}", p[0], p[1], p[2]),
target: p[0].into(),
})
}
}
}
let branches = git_service::git_text(
&repo_path,
&["branch", "--all", "--format=%(refname:short)"],
)?;
for b in branches.lines() {
if matches(&query, b) {
r.push(SearchResult {
kind: "branch".into(),
title: b.into(),
subtitle: "branch".into(),
target: b.into(),
})
}
}
let files = git_service::git_text(&repo_path, &["ls-files"])?;
for f in files.lines().take(limit as usize * 4) {
if matches(&query, f) {
r.push(SearchResult {
kind: "file".into(),
title: f.into(),
subtitle: "tracked file".into(),
target: f.into(),
})
}
}
r.truncate(limit as usize);
Ok(r)
}
16 changes: 16 additions & 0 deletions src-tauri/src/commands/stash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,19 @@ pub fn pop_stash(repo_path: String, stash: String) -> Result<GitCommandOutput, G
pub fn drop_stash(repo_path: String, stash: String) -> Result<GitCommandOutput, GitError> {
git_service::git_checked(&repo_path, &["stash", "drop", &stash])
}

#[tauri::command]
pub fn rename_stash(
repo_path: String,
stash: String,
message: String,
) -> Result<GitCommandOutput, GitError> {
let patch = git_service::git_text(&repo_path, &["stash", "show", "-p", &stash])?;
let branch = format!("gitpilot-stash-rename-{}", std::process::id());
git_service::git_checked(&repo_path, &["stash", "branch", &branch, &stash])?;
let out = git_service::git_checked(&repo_path, &["stash", "push", "-m", message.trim()])?;
let _ = git_service::git_checked(&repo_path, &["checkout", "-"]);
let _ = git_service::git_checked(&repo_path, &["branch", "-D", &branch]);
let _ = patch;
Ok(out)
}
64 changes: 64 additions & 0 deletions src-tauri/src/commands/worktree.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
use crate::{
models::git::{GitCommandOutput, GitError, WorktreeInfo},
services::git_service,
};

#[tauri::command]
pub fn list_worktrees(repo_path: String) -> Result<Vec<WorktreeInfo>, GitError> {
let out = git_service::git_text(&repo_path, &["worktree", "list", "--porcelain"])?;
let mut items = Vec::new();
let mut cur: Option<WorktreeInfo> = None;
for line in out.lines() {
if let Some(path) = line.strip_prefix("worktree ") {
if let Some(item) = cur.take() {
items.push(item);
}
cur = Some(WorktreeInfo {
path: path.into(),
head: String::new(),
branch: None,
bare: false,
detached: false,
});
} else if let Some(item) = cur.as_mut() {
if let Some(head) = line.strip_prefix("HEAD ") {
item.head = head.into();
} else if let Some(branch) = line.strip_prefix("branch ") {
item.branch = Some(branch.trim_start_matches("refs/heads/").into());
} else if line == "bare" {
item.bare = true;
} else if line == "detached" {
item.detached = true;
}
}
}
if let Some(item) = cur {
items.push(item);
}
Ok(items)
}
#[tauri::command]
pub fn create_worktree(
repo_path: String,
path: String,
branch: String,
new_branch: bool,
) -> Result<GitCommandOutput, GitError> {
if new_branch {
git_service::git_checked(&repo_path, &["worktree", "add", "-b", &branch, &path])
} else {
git_service::git_checked(&repo_path, &["worktree", "add", &path, &branch])
}
}
#[tauri::command]
pub fn remove_worktree(
repo_path: String,
path: String,
force: bool,
) -> Result<GitCommandOutput, GitError> {
if force {
git_service::git_checked(&repo_path, &["worktree", "remove", "--force", &path])
} else {
git_service::git_checked(&repo_path, &["worktree", "remove", &path])
}
}
9 changes: 9 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub fn run() {
commands::history::cherry_pick_commit,
commands::history::revert_commit,
commands::history::reset_to_commit,
commands::history::abort_cherry_pick,
commands::history::blame_file,
commands::merge::merge_branch,
commands::merge::abort_merge,
commands::merge::continue_merge,
Expand All @@ -51,17 +53,24 @@ pub fn run() {
commands::rebase::continue_rebase,
commands::rebase::abort_rebase,
commands::rebase::skip_rebase,
commands::rebase::get_rebase_state,
commands::rebase::start_interactive_rebase,
commands::stash::list_stashes,
commands::stash::create_stash,
commands::stash::apply_stash,
commands::stash::pop_stash,
commands::stash::drop_stash,
commands::stash::rename_stash,
commands::tag::list_tags,
commands::tag::create_lightweight_tag,
commands::tag::create_annotated_tag,
commands::tag::delete_tag,
commands::tag::push_tag,
commands::validation::run_validation,
commands::worktree::list_worktrees,
commands::worktree::create_worktree,
commands::worktree::remove_worktree,
commands::search::smart_search,
commands::ai::ai_complete,
commands::ai::explain_diff,
commands::ai::generate_commit_message,
Expand Down
Loading
Loading