codetether_agent/a2a/git_credentials/
repo_config.rs1use anyhow::{Result, anyhow};
13use std::path::{Path, PathBuf};
14
15use super::git_config::{run_git_command, set_local_config};
16use super::write_git_credential_helper_script;
17
18pub fn configure_repo_git_auth(repo_path: &Path, workspace_id: &str) -> Result<PathBuf> {
28 let helper_path = repo_path.join(".codetether-git-credential-helper");
29 write_git_credential_helper_script(&helper_path, workspace_id)?;
30 let helper_path_str = helper_path
31 .to_str()
32 .ok_or_else(|| anyhow!("Helper path is not valid UTF-8"))?;
33 run_git_command(
34 repo_path,
35 &["config", "--local", "credential.helper", helper_path_str],
36 )?;
37 run_git_command(
38 repo_path,
39 &["config", "--local", "credential.useHttpPath", "true"],
40 )?;
41 run_git_command(
42 repo_path,
43 &["config", "--local", "codetether.workspaceId", workspace_id],
44 )?;
45 Ok(helper_path)
46}
47
48pub fn configure_repo_git_github_app(
58 repo_path: &Path,
59 installation_id: Option<&str>,
60 app_id: Option<&str>,
61) -> Result<()> {
62 set_local_config(
63 repo_path,
64 "codetether.githubInstallationId",
65 installation_id,
66 )?;
67 set_local_config(repo_path, "codetether.githubAppId", app_id)?;
68 Ok(())
69}