diff --git a/Cargo.lock b/Cargo.lock index 39e251a66..8c5d82baf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -203,7 +203,7 @@ dependencies = [ [[package]] name = "git-ai" -version = "0.1.0" +version = "0.1.1" dependencies = [ "clap", "git2", diff --git a/Cargo.toml b/Cargo.toml index 1ff9b2490..4f25ac945 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git-ai" -version = "0.1.0" +version = "0.1.1" edition = "2024" diff --git a/Readme.md b/Readme.md index 95b1c17d0..3dd4bae19 100644 --- a/Readme.md +++ b/Readme.md @@ -53,9 +53,9 @@ git-ai init > If you are not using Claude Code, you'll need to manually mark AI contributions by running `git-ai checkpoint --author 'Cursor'` after approving generated code. Automatic support for Cursor, Codex, Copilot support coming soon! -3. Add hooks to Claude Code +3. Add hooks to Claude Code [`.claude/settings.local.json`](https://docs.anthropic.com/en/docs/claude-code/hooks) -```json file=".claude/settings.local.json" +```json { "hooks": { "PreToolUse": [ diff --git a/src/git/refs.rs b/src/git/refs.rs index f073f3740..90e1118ad 100644 --- a/src/git/refs.rs +++ b/src/git/refs.rs @@ -70,23 +70,6 @@ pub fn setup_ai_refspecs(repo: &Repository) -> Result<(), GitAiError> { for i in 0..remotes.len() { if let Some(remote_name) = remotes.get(i) { - // Check if default fetch refspec exists, if not add it - let fetch_output = std::process::Command::new("git") - .args(["config", "--get", &format!("remote.{}.fetch", remote_name)]) - .output()?; - - if fetch_output.stdout.is_empty() { - // No fetch refspec exists, add the default one first - std::process::Command::new("git") - .args([ - "config", - "--add", - &format!("remote.{}.fetch", remote_name), - "+refs/heads/*:refs/remotes/{}/*", - ]) - .status()?; - } - // Check if AI fetch refspec already exists let ai_fetch_output = std::process::Command::new("git") .args([ @@ -121,8 +104,21 @@ pub fn setup_ai_refspecs(repo: &Repository) -> Result<(), GitAiError> { ); } + // Check if AI push refspec already exists + let ai_push_output = std::process::Command::new("git") + .args([ + "config", + "--get-all", + &format!("remote.{}.push", remote_name), + ]) + .output()?; + + let ai_push_exists = String::from_utf8_lossy(&ai_push_output.stdout) + .lines() + .any(|line| line.trim() == "refs/ai/*:refs/ai/*"); + // Check if default push refspec exists, if not add it - let push_output = std::process::Command::new("git") + let default_push_output = std::process::Command::new("git") .args([ "config", "--get-all", @@ -130,12 +126,12 @@ pub fn setup_ai_refspecs(repo: &Repository) -> Result<(), GitAiError> { ]) .output()?; - let default_push_exists = String::from_utf8_lossy(&push_output.stdout) + let default_push_exists = String::from_utf8_lossy(&default_push_output.stdout) .lines() .any(|line| line.trim() == "refs/heads/*:refs/heads/*"); if !default_push_exists { - // No default push refspec exists, add it first + // Add default push refspec first let default_push_status = std::process::Command::new("git") .args([ "config", @@ -150,19 +146,6 @@ pub fn setup_ai_refspecs(repo: &Repository) -> Result<(), GitAiError> { } } - // Check if AI push refspec already exists - let ai_push_output = std::process::Command::new("git") - .args([ - "config", - "--get-all", - &format!("remote.{}.push", remote_name), - ]) - .output()?; - - let ai_push_exists = String::from_utf8_lossy(&ai_push_output.stdout) - .lines() - .any(|line| line.trim() == "refs/ai/*:refs/ai/*"); - // Add AI push refspec only if it doesn't exist if !ai_push_exists { let push_status = std::process::Command::new("git")