MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / add_remote

Method add_remote

atomic-cli/src/commands/remote/mod.rs:185–213  ·  view source on GitHub ↗

Add a new remote.

(&self, add: &RemoteAdd)

Source from the content-addressed store, hash-verified

183
184 /// Add a new remote.
185 fn add_remote(&self, add: &RemoteAdd) -> CliResult<()> {
186 let repo_root = find_repository_root()?;
187 let repo = Repository::open(&repo_root).map_err(CliError::Repository)?;
188
189 // Check if URL is valid
190 if !add.url.contains("://") {
191 return Err(CliError::InvalidArgument {
192 message: format!(
193 "Invalid URL '{}': URL must include a scheme (e.g., https://)",
194 add.url
195 ),
196 });
197 }
198
199 if add.default {
200 repo.add_remote_default(&add.name, &add.url)
201 .map_err(CliError::Repository)?;
202 } else {
203 repo.add_remote(&add.name, &add.url)
204 .map_err(CliError::Repository)?;
205 }
206
207 print_success(&format!("Remote '{}' added", add.name));
208 if self.verbose {
209 println!(" URL: {}", add.url);
210 }
211
212 Ok(())
213 }
214
215 /// Remove a remote.
216 fn remove_remote(&self, remove: &RemoteRemove) -> CliResult<()> {

Callers 2

runMethod · 0.45
executeMethod · 0.45

Calls 4

find_repository_rootFunction · 0.85
print_successFunction · 0.85
add_remote_defaultMethod · 0.80
containsMethod · 0.45

Tested by

no test coverage detected