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

Method add

atomic-repository/src/remote.rs:476–504  ·  view source on GitHub ↗

Add a new remote. # Arguments `name` - The name for the new remote `entry` - The remote configuration # Errors Returns an error if: - A remote with the same name already exists - The name is invalid - The URL is invalid # Example ```rust use atomic_repository::remote::{RemoteConfig, RemoteEntry}; let mut config = RemoteConfig::new(); config.add("origin", RemoteEntry::new("https://example.co

(&mut self, name: &str, entry: RemoteEntry)

Source from the content-addressed store, hash-verified

474 /// assert!(config.contains("origin"));
475 /// ```
476 pub fn add(&mut self, name: &str, entry: RemoteEntry) -> RemoteResult<()> {
477 // Validate name
478 validate_remote_name(name)?;
479
480 // Validate URL
481 if !entry.is_valid_url() {
482 return Err(RemoteError::InvalidUrl {
483 url: entry.url.clone(),
484 reason: "URL must include a scheme (e.g., https://)".to_string(),
485 });
486 }
487
488 // Check for duplicates
489 if self.remotes.contains_key(name) {
490 return Err(RemoteError::AlreadyExists {
491 name: name.to_string(),
492 });
493 }
494
495 // If this is marked as default, unmark any existing default
496 if entry.default {
497 for existing in self.remotes.values_mut() {
498 existing.default = false;
499 }
500 }
501
502 self.remotes.insert(name.to_string(), entry);
503 Ok(())
504 }
505
506 /// Remove a remote by name.
507 ///

Calls 5

validate_remote_nameFunction · 0.85
is_valid_urlMethod · 0.80
contains_keyMethod · 0.80
cloneMethod · 0.45
insertMethod · 0.45