← back to ddgonzal3__rally

Function bodies 465 total

All specs Real LLM only Function bodies
remove_workspace_path function · rust · L262-L278 (17 LOC)
src-tauri/src/commands.rs
pub fn remove_workspace_path(
    app: tauri::AppHandle,
    id: String,
    path: String,
) -> Result<Workspace, String> {
    let mut workspaces = workspace::load_workspaces();
    let ws = workspaces
        .iter_mut()
        .find(|w| w.id == id)
        .ok_or_else(|| format!("Workspace not found: {}", id))?;

    ws.paths.retain(|p| p != &path);
    let result = ws.clone();
    workspace::save_workspaces(&workspaces)?;
    emit_workspaces_updated(&app);
    Ok(result)
}
set_workspace_paths function · rust · L281-L297 (17 LOC)
src-tauri/src/commands.rs
pub fn set_workspace_paths(
    app: tauri::AppHandle,
    id: String,
    paths: Vec<String>,
) -> Result<Workspace, String> {
    let mut workspaces = workspace::load_workspaces();
    let ws = workspaces
        .iter_mut()
        .find(|w| w.id == id)
        .ok_or_else(|| format!("Workspace not found: {}", id))?;

    ws.paths = paths;
    let result = ws.clone();
    workspace::save_workspaces(&workspaces)?;
    emit_workspaces_updated(&app);
    Ok(result)
}
reorder_workspace_path function · rust · L300-L333 (34 LOC)
src-tauri/src/commands.rs
pub fn reorder_workspace_path(
    app: tauri::AppHandle,
    workspace_id: String,
    path: String,
    to_index: usize,
) -> Result<Workspace, String> {
    let mut workspaces = workspace::load_workspaces();
    let ws = workspaces
        .iter_mut()
        .find(|w| w.id == workspace_id)
        .ok_or_else(|| format!("Workspace not found: {}", workspace_id))?;

    if ws.paths.len() <= 1 {
        return Ok(ws.clone());
    }

    let from_index = ws
        .paths
        .iter()
        .position(|p| p == &path)
        .ok_or_else(|| format!("Path not found in workspace: {}", path))?;
    let target = to_index.min(ws.paths.len() - 1);
    if from_index == target {
        return Ok(ws.clone());
    }

    let moved = ws.paths.remove(from_index);
    ws.paths.insert(target, moved);
    let result = ws.clone();

    workspace::save_workspaces(&workspaces)?;
    emit_workspaces_updated(&app);
    Ok(result)
}
clone_repo function · rust · L336-L366 (31 LOC)
src-tauri/src/commands.rs
pub async fn clone_repo(source_path: String, name: String) -> Result<String, String> {
    let source = std::path::Path::new(&source_path);
    let parent = source.parent().ok_or("Cannot determine parent directory")?;
    let target = parent.join(&name);

    if target.exists() {
        return Err(format!("Directory already exists: {}", target.display()));
    }

    let target_str = target.to_string_lossy().to_string();

    // Get the original remote URL before cloning
    let remote_url = crate::git_ops::git_cmd(&source_path, &["remote", "get-url", "origin"])
        .await
        .unwrap_or_default();

    // Clone from local source (fast, no network)
    crate::git_ops::git_cmd(
        &parent.to_string_lossy(),
        &["clone", &source_path, &name],
    )
    .await?;

    // Point remote at the real upstream (not the local sibling)
    if !remote_url.is_empty() {
        crate::git_ops::git_cmd(&target_str, &["remote", "set-url", "origin", &remote_url])
            .await?;
git_status function · rust · L369-L371 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_status(workspace_path: String, main_branch: String) -> Result<GitStatus, String> {
    git_ops::status(&workspace_path, &main_branch).await
}
git_pr_status function · rust · L374-L376 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_pr_status(workspace_path: String) -> Result<PrStatus, String> {
    git_ops::pr_status(&workspace_path).await
}
git_pr_details function · rust · L379-L381 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_pr_details(workspace_path: String) -> Result<PrDetails, String> {
    git_ops::pr_details(&workspace_path).await
}
All rows above produced by Repobility · https://repobility.com
git_pr_diff function · rust · L384-L386 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_pr_diff(workspace_path: String) -> Result<String, String> {
    git_ops::pr_diff(&workspace_path).await
}
git_edit_pr_title function · rust · L389-L391 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_edit_pr_title(workspace_path: String, title: String) -> Result<(), String> {
    git_ops::edit_pr_title(&workspace_path, &title).await
}
git_close_pr function · rust · L394-L396 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_close_pr(workspace_path: String) -> Result<String, String> {
    git_ops::close_pr(&workspace_path).await
}
git_merge_pr function · rust · L399-L401 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_merge_pr(workspace_path: String, method: String) -> Result<String, String> {
    git_ops::merge_pr(&workspace_path, &method).await
}
git_changes function · rust · L404-L406 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_changes(workspace_path: String) -> Result<ChangesSummary, String> {
    git_ops::changes(&workspace_path).await
}
git_file_at_head function · rust · L409-L411 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_file_at_head(workspace_path: String, file_path: String) -> Result<String, String> {
    git_ops::file_at_head(&workspace_path, &file_path).await
}
git_stage_file function · rust · L414-L416 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_stage_file(workspace_path: String, file_path: String) -> Result<(), String> {
    git_ops::stage_file(&workspace_path, &file_path).await
}
git_unstage_file function · rust · L419-L421 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_unstage_file(workspace_path: String, file_path: String) -> Result<(), String> {
    git_ops::unstage_file(&workspace_path, &file_path).await
}
Repobility · open methodology · https://repobility.com/research/
git_discard_file function · rust · L424-L430 (7 LOC)
src-tauri/src/commands.rs
pub async fn git_discard_file(
    workspace_path: String,
    file_path: String,
    is_untracked: bool,
) -> Result<(), String> {
    git_ops::discard_file(&workspace_path, &file_path, is_untracked).await
}
git_diff function · rust · L433-L435 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_diff(workspace_path: String, staged: bool) -> Result<String, String> {
    git_ops::diff(&workspace_path, staged).await
}
git_apply_patch function · rust · L438-L440 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_apply_patch(workspace_path: String, patch: String, reverse: bool, cached: bool) -> Result<String, String> {
    git_ops::apply_patch(&workspace_path, &patch, reverse, cached).await
}
git_commit_staged function · rust · L443-L445 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_commit_staged(workspace_path: String, message: String) -> Result<String, String> {
    git_ops::commit_staged(&workspace_path, &message).await
}
git_push function · rust · L448-L450 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_push(workspace_path: String) -> Result<PushResult, String> {
    git_ops::push(&workspace_path).await
}
git_create_pr function · rust · L453-L455 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_create_pr(workspace_path: String) -> Result<String, String> {
    git_ops::create_pr(&workspace_path, None, None).await
}
git_commit_log function · rust · L458-L460 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_commit_log(workspace_path: String, main_branch: String, limit: u32) -> Result<Vec<CommitEntry>, String> {
    git_ops::commit_log(&workspace_path, &main_branch, limit).await
}
git_commit_diff function · rust · L463-L465 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_commit_diff(workspace_path: String, sha: String) -> Result<String, String> {
    git_ops::commit_diff(&workspace_path, &sha).await
}
Citation: Repobility (2026). State of AI-Generated Code. https://repobility.com/research/
git_diff_stat function · rust · L468-L470 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_diff_stat(workspace_path: String) -> Result<(i64, i64), String> {
    git_ops::diff_stat(&workspace_path).await
}
git_fetch function · rust · L473-L475 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_fetch(workspace_path: String) -> Result<(), String> {
    git_ops::fetch(&workspace_path).await
}
git_pull function · rust · L478-L480 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_pull(workspace_path: String) -> Result<String, String> {
    git_ops::pull(&workspace_path).await
}
git_force_pull function · rust · L483-L485 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_force_pull(workspace_path: String) -> Result<String, String> {
    git_ops::force_pull(&workspace_path).await
}
git_rebase_on_main function · rust · L488-L490 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_rebase_on_main(workspace_path: String, main_branch: String) -> Result<String, String> {
    git_ops::rebase_on_main(&workspace_path, &main_branch).await
}
git_sync function · rust · L493-L495 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_sync(workspace_path: String, main_branch: String) -> Result<String, String> {
    git_ops::sync_branch(&workspace_path, &main_branch).await
}
git_stash function · rust · L498-L500 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_stash(workspace_path: String) -> Result<String, String> {
    git_ops::stash(&workspace_path).await
}
git_stash_pop function · rust · L503-L505 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_stash_pop(workspace_path: String) -> Result<String, String> {
    git_ops::stash_pop(&workspace_path).await
}
Powered by Repobility — scan your code at https://repobility.com
git_stash_count function · rust · L508-L510 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_stash_count(workspace_path: String) -> Result<u32, String> {
    git_ops::stash_count(&workspace_path).await
}
git_list_branches function · rust · L513-L515 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_list_branches(workspace_path: String) -> Result<Vec<git_ops::BranchInfo>, String> {
    git_ops::list_branches(&workspace_path).await
}
git_checkout_branch function · rust · L518-L520 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_checkout_branch(workspace_path: String, branch: String) -> Result<String, String> {
    git_ops::checkout_branch(&workspace_path, &branch).await
}
git_create_branch function · rust · L523-L525 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_create_branch(workspace_path: String, branch: String) -> Result<String, String> {
    git_ops::create_branch(&workspace_path, &branch).await
}
git_delete_branch function · rust · L528-L530 (3 LOC)
src-tauri/src/commands.rs
pub async fn git_delete_branch(workspace_path: String, branch: String, force: bool) -> Result<String, String> {
    git_ops::delete_branch(&workspace_path, &branch, force).await
}
trash_file function · rust · L533-L539 (7 LOC)
src-tauri/src/commands.rs
pub fn trash_file(path: String) -> Result<(), String> {
    let p = Path::new(&path);
    if !p.exists() {
        return Err(format!("Path does not exist: {}", path));
    }
    trash::delete(&path).map_err(|e| format!("Failed to move to trash: {}", e))
}
rename_file function · rust · L542-L551 (10 LOC)
src-tauri/src/commands.rs
pub fn rename_file(old_path: String, new_path: String) -> Result<(), String> {
    let p = Path::new(&old_path);
    if !p.exists() {
        return Err(format!("Path does not exist: {}", old_path));
    }
    if Path::new(&new_path).exists() {
        return Err(format!("Already exists: {}", new_path));
    }
    fs::rename(&old_path, &new_path).map_err(|e| format!("Failed to rename: {}", e))
}
reveal_in_finder function · rust · L554-L562 (9 LOC)
src-tauri/src/commands.rs
pub fn reveal_in_finder(path: String) -> Result<(), String> {
    let p = Path::new(&path);
    if p.is_dir() {
        Command::new("open").arg(&path).spawn().map_err(|e| e.to_string())?;
    } else {
        Command::new("open").arg("-R").arg(&path).spawn().map_err(|e| e.to_string())?;
    }
    Ok(())
}
All rows above produced by Repobility · https://repobility.com
kill_port function · rust · L566-L588 (23 LOC)
src-tauri/src/commands.rs
pub fn kill_port(port: u16) -> Result<(), String> {
    // Use lsof to find the PID listening on the port
    let output = Command::new("lsof")
        .args(["-ti", &format!(":{}", port)])
        .output()
        .map_err(|e| format!("Failed to run lsof: {}", e))?;

    let pids = String::from_utf8_lossy(&output.stdout);
    let pids: Vec<&str> = pids.trim().split('\n').filter(|s| !s.is_empty()).collect();

    if pids.is_empty() {
        return Err(format!("No process found on port {}", port));
    }

    for pid in &pids {
        Command::new("kill")
            .args(["-9", pid])
            .output()
            .map_err(|e| format!("Failed to kill PID {}: {}", pid, e))?;
    }

    Ok(())
}
read_rally_config function · rust · L619-L634 (16 LOC)
src-tauri/src/commands.rs
pub fn read_rally_config(root_path: String) -> Result<RallyConfig, String> {
    let rally_json = Path::new(&root_path).join("RALLY.json");
    if !rally_json.exists() {
        return Ok(RallyConfig {
            exclude_builtins: Vec::new(),
            exclude_scripts: Vec::new(),
            mode: None,
            setup: None,
            status_bar: Vec::new(),
        });
    }
    let content = fs::read_to_string(&rally_json)
        .map_err(|e| format!("Failed to read RALLY.json: {}", e))?;
    serde_json::from_str(&content)
        .map_err(|e| format!("Failed to parse RALLY.json: {}", e))
}
update_rally_config_status_bar function · rust · L637-L653 (17 LOC)
src-tauri/src/commands.rs
pub fn update_rally_config_status_bar(root_path: String, scripts: Vec<String>) -> Result<(), String> {
    let rally_json = Path::new(&root_path).join("RALLY.json");
    let mut config: serde_json::Value = if rally_json.exists() {
        let content = fs::read_to_string(&rally_json)
            .map_err(|e| format!("Failed to read RALLY.json: {}", e))?;
        serde_json::from_str(&content)
            .map_err(|e| format!("Failed to parse RALLY.json: {}", e))?
    } else {
        serde_json::json!({})
    };
    config["statusBar"] = serde_json::json!(scripts);
    let pretty = serde_json::to_string_pretty(&config)
        .map_err(|e| format!("Failed to serialize RALLY.json: {}", e))?;
    fs::write(&rally_json, pretty + "\n")
        .map_err(|e| format!("Failed to write RALLY.json: {}", e))?;
    Ok(())
}
check_dir_readiness function · rust · L659-L694 (36 LOC)
src-tauri/src/commands.rs
fn check_dir_readiness(dir: &Path, label: &str) -> Vec<String> {
    let mut issues: Vec<String> = Vec::new();
    let prefix = if label.is_empty() {
        String::new()
    } else {
        format!("{}: ", label)
    };

    // package.json exists but no node_modules/
    if dir.join("package.json").exists() && !dir.join("node_modules").is_dir() {
        issues.push(format!("{}Dependencies not installed", prefix));
    }

    // Cargo.toml exists but no target/
    if dir.join("Cargo.toml").exists() && !dir.join("target").is_dir() {
        issues.push(format!("{}Rust project not built", prefix));
    }

    // CMakeLists.txt exists but no build/
    if dir.join("CMakeLists.txt").exists() && !dir.join("build").is_dir() {
        issues.push(format!("{}C++ project not built", prefix));
    }

    // .env.example exists but no .env
    if dir.join(".env.example").exists() && !dir.join(".env").exists() {
        issues.push(format!("{}Environment not configured", prefix));
    }

    
check_workspace_ready function · rust · L697-L764 (68 LOC)
src-tauri/src/commands.rs
pub async fn check_workspace_ready(root_path: String) -> Result<WorkspaceReadiness, String> {
    // Run on a blocking thread so we don't stall the main/async runtime
    tokio::task::spawn_blocking(move || {
        let root = Path::new(&root_path);
        let mut issues: Vec<String> = Vec::new();

        // Check root directory
        issues.extend(check_dir_readiness(root, ""));

        // Check immediate subdirectories (monorepo support)
        if let Ok(entries) = fs::read_dir(root) {
            for entry in entries.filter_map(|e| e.ok()) {
                if !entry.file_type().map(|ft| ft.is_dir()).unwrap_or(false) {
                    continue;
                }
                let name = entry.file_name().to_string_lossy().to_string();
                // Skip hidden dirs and common non-project dirs
                if name.starts_with('.') || HIDDEN_DIRS.contains(&name.as_str()) {
                    continue;
                }
                issues.extend(check_dir_read
builtin_commands function · rust · L782-L802 (21 LOC)
src-tauri/src/commands.rs
fn builtin_commands() -> Vec<ScriptEntry> {
    let cmd_dir = crate::ship_ops::rally_commands_dir()
        .unwrap_or_else(|_| std::path::PathBuf::from("."));

    vec![
        ScriptEntry {
            name: "rally-ship".to_string(),
            label: "/rally-ship".to_string(),
            command: "claude:/rally-ship".to_string(),
            builtin: true,
            file_path: Some(cmd_dir.join("rally-ship.md").to_string_lossy().to_string()),
        },
        ScriptEntry {
            name: "rally-review-pr".to_string(),
            label: "/rally-review-pr".to_string(),
            command: "claude:/rally-review-pr".to_string(),
            builtin: true,
            file_path: Some(cmd_dir.join("rally-review-pr.md").to_string_lossy().to_string()),
        },
    ]
}
discover_scripts function · rust · L805-L844 (40 LOC)
src-tauri/src/commands.rs
fn discover_scripts(root_path: &str, exclude: &[String]) -> Vec<ScriptEntry> {
    let scripts_dir = Path::new(root_path).join("scripts");
    if !scripts_dir.is_dir() {
        return Vec::new();
    }

    let mut scripts: Vec<ScriptEntry> = fs::read_dir(&scripts_dir)
        .into_iter()
        .flatten() // Result<ReadDir> → ReadDir
        .flatten() // DirEntry results
        .filter_map(|entry| {
            let name = entry.file_name().to_string_lossy().to_string();
            let lower = name.to_lowercase();

            // Only include script files
            if !SCRIPT_EXTENSIONS.iter().any(|ext| lower.ends_with(ext)) {
                return None;
            }
            // Skip excluded scripts
            if exclude.iter().any(|ex| ex == &name) {
                return None;
            }

            let full_path = entry.path().to_string_lossy().to_string();
            let interpreter = if lower.ends_with(".zsh") { "zsh" } else { "bash" };
            let command
file_exists function · rust · L847-L849 (3 LOC)
src-tauri/src/commands.rs
pub fn file_exists(path: String) -> bool {
    Path::new(&path).is_file()
}
Repobility · open methodology · https://repobility.com/research/
read_clipboard_text function · rust · L854-L863 (10 LOC)
src-tauri/src/commands.rs
pub fn read_clipboard_text() -> Result<String, String> {
    let output = Command::new("pbpaste")
        .output()
        .map_err(|e| format!("Failed to run pbpaste: {}", e))?;
    if !output.status.success() {
        return Err("pbpaste failed".to_string());
    }
    String::from_utf8(output.stdout)
        .map_err(|e| format!("Clipboard content is not valid UTF-8: {}", e))
}
save_clipboard_image function · rust · L868-L894 (27 LOC)
src-tauri/src/commands.rs
pub fn save_clipboard_image(data: String, mime_type: String) -> Result<String, String> {
    let ext = match mime_type.as_str() {
        "image/png" => "png",
        "image/jpeg" | "image/jpg" => "jpg",
        "image/gif" => "gif",
        "image/webp" => "webp",
        "image/bmp" => "bmp",
        _ => "png", // default to png
    };

    let bytes = base64::engine::general_purpose::STANDARD
        .decode(&data)
        .map_err(|e| format!("Failed to decode base64: {}", e))?;

    let dir = std::env::temp_dir().join("rally-clipboard");
    fs::create_dir_all(&dir).map_err(|e| format!("Failed to create temp dir: {}", e))?;

    let filename = format!(
        "paste-{}.{}",
        uuid::Uuid::new_v4().to_string().split('-').next().unwrap_or("img"),
        ext
    );
    let path = dir.join(&filename);
    fs::write(&path, &bytes).map_err(|e| format!("Failed to write image: {}", e))?;

    Ok(path.to_string_lossy().to_string())
}
list_scripts function · rust · L897-L949 (53 LOC)
src-tauri/src/commands.rs
pub fn list_scripts(root_path: String) -> Result<Vec<ScriptEntry>, String> {
    let rally_json = Path::new(&root_path).join("RALLY.json");

    let (exclude_builtins, exclude_scripts) = if rally_json.exists() {
        let content = fs::read_to_string(&rally_json)
            .map_err(|e| format!("Failed to read RALLY.json: {}", e))?;
        let config: RallyConfig = serde_json::from_str(&content)
            .map_err(|e| format!("Failed to parse RALLY.json: {}", e))?;
        (config.exclude_builtins, config.exclude_scripts)
    } else {
        (Vec::new(), Vec::new())
    };

    let mut entries: Vec<ScriptEntry> = Vec::new();

    // Check for repo-level Claude commands that override built-ins.
    // If the repo has its own .claude/commands/<name>.md (a real file, not
    // a symlink to Rally's version), skip the built-in so the repo's
    // command takes precedence.
    let repo_commands_dir = Path::new(&root_path).join(".claude").join("commands");
    let rally_commands = cr
‹ prevpage 7 / 10next ›