MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / add_remote

Function add_remote

src/git_operations.rs:163–187  ·  view source on GitHub ↗
(repo_path: &Path, remote_name: &str, url: &str)

Source from the content-addressed store, hash-verified

161}
162
163pub async fn add_remote(repo_path: &Path, remote_name: &str, url: &str) -> Result<(), String> {
164 tokio::task::spawn_blocking({
165 let repo_path = repo_path.to_owned();
166 let remote_name = remote_name.to_owned();
167 let url = url.to_owned();
168 move || -> Result<(), String> {
169 let repo = Repository::open(&repo_path)
170 .map_err(|e| format!("Failed to open repository: {e}"))?;
171
172 let result = repo.remote(&remote_name, &url);
173 match result {
174 Ok(_) => Ok(()),
175 Err(e) => {
176 if e.code() == git2::ErrorCode::Exists {
177 Ok(())
178 } else {
179 Err(format!("Failed to add remote: {e}"))
180 }
181 }
182 }
183 }
184 })
185 .await
186 .map_err(|e| format!("Task join error: {e}"))?
187}
188
189pub async fn fetch_branch(
190 repo_path: &Path,

Callers 3

fetch_changesMethod · 0.85

Calls

no outgoing calls

Tested by 1