Skip to content

Commit 079f308

Browse files
aster-voidclaude
andcommitted
git: fix local repo support
Use rsync for sync_to_job_dir when .git directory doesn't exist (local repos copied without .git). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent a2b93df commit 079f308

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

src/git.rs

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,43 @@ pub fn sync_to_job_dir(sot_path: &Path, job_dir: &Path) -> Result<()> {
132132
}
133133
std::fs::create_dir_all(job_dir)?;
134134

135-
let archive = Command::new("git")
136-
.args(["archive", "HEAD"])
137-
.current_dir(sot_path)
138-
.output()?;
135+
// Check if .git exists (remote repos have it, local rsync'd repos don't)
136+
if sot_path.join(".git").exists() {
137+
// Use git archive for git repos
138+
let archive = Command::new("git")
139+
.args(["archive", "HEAD"])
140+
.current_dir(sot_path)
141+
.output()?;
139142

140-
if !archive.status.success() {
141-
let stderr = String::from_utf8_lossy(&archive.stderr);
142-
anyhow::bail!("git archive failed: {}", stderr);
143-
}
143+
if !archive.status.success() {
144+
let stderr = String::from_utf8_lossy(&archive.stderr);
145+
anyhow::bail!("git archive failed: {}", stderr);
146+
}
144147

145-
let extract = Command::new("tar")
146-
.args(["-x"])
147-
.current_dir(job_dir)
148-
.stdin(std::process::Stdio::piped())
149-
.spawn()?;
148+
let extract = Command::new("tar")
149+
.args(["-x"])
150+
.current_dir(job_dir)
151+
.stdin(std::process::Stdio::piped())
152+
.spawn()?;
150153

151-
use std::io::Write;
152-
extract.stdin.unwrap().write_all(&archive.stdout)?;
154+
use std::io::Write;
155+
extract.stdin.unwrap().write_all(&archive.stdout)?;
156+
} else {
157+
// For non-git dirs (rsync'd local repos), use rsync
158+
let output = Command::new("rsync")
159+
.args([
160+
"-a",
161+
"--delete",
162+
&format!("{}/", sot_path.to_str().unwrap()),
163+
job_dir.to_str().unwrap(),
164+
])
165+
.output()?;
166+
167+
if !output.status.success() {
168+
let stderr = String::from_utf8_lossy(&output.stderr);
169+
anyhow::bail!("rsync failed: {}", stderr);
170+
}
171+
}
153172

154173
Ok(())
155174
}

0 commit comments

Comments
 (0)