(cwd: &Path, args: &[&str])
| 30 | } |
| 31 | |
| 32 | async fn run_git(cwd: &Path, args: &[&str]) -> Result<String> { |
| 33 | let output = Command::new("git") |
| 34 | .args(args) |
| 35 | .current_dir(cwd) |
| 36 | .env_remove("GIT_DIR") |
| 37 | .env_remove("GIT_WORK_TREE") |
| 38 | .env_remove("GIT_INDEX_FILE") |
| 39 | .output() |
| 40 | .await?; |
| 41 | |
| 42 | if !output.status.success() { |
| 43 | return Err(GitError::CommandFailed { |
| 44 | command: format!("git {}", args.join(" ")), |
| 45 | stdout: String::from_utf8_lossy(&output.stdout).to_string(), |
| 46 | stderr: String::from_utf8_lossy(&output.stderr).to_string(), |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | Ok(String::from_utf8_lossy(&output.stdout).trim().to_string()) |
| 51 | } |
| 52 | |
| 53 | pub async fn is_git_repo(path: &Path) -> bool { |
| 54 | tokio::fs::symlink_metadata(path.join(".git")).await.is_ok() |
no outgoing calls