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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "git-ai"
version = "0.1.0"
version = "0.1.1"
edition = "2024"


Expand Down
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
49 changes: 16 additions & 33 deletions src/git/refs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -121,21 +104,34 @@ 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",
&format!("remote.{}.push", remote_name),
])
.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",
Expand All @@ -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")
Expand Down