MCPcopy Create free account
hub / github.com/brocode/fw / add_remote

Function add_remote

src/project/mod.rs:74–92  ·  view source on GitHub ↗
(maybe_config: Result<Config, AppError>, name: &str, remote_name: String, git: String)

Source from the content-addressed store, hash-verified

72}
73
74pub fn add_remote(maybe_config: Result<Config, AppError>, name: &str, remote_name: String, git: String) -> Result<(), AppError> {
75 let config: Config = maybe_config?;
76 if !config.projects.contains_key(name) {
77 return Err(AppError::UserError(format!("Project key {} does not exists. Can not update.", name)));
78 }
79 let mut project_config: Project = config.projects.get(name).expect("Already checked in the if above").clone();
80 let mut additional_remotes = project_config.additional_remotes.unwrap_or_default();
81 if additional_remotes.iter().any(|r| r.name == remote_name) {
82 return Err(AppError::UserError(format!(
83 "Remote {} for project {} does already exist. Can not add.",
84 remote_name, name
85 )));
86 }
87 additional_remotes.push(Remote { name: remote_name, git });
88 project_config.additional_remotes = Some(additional_remotes);
89
90 config::write_project(&project_config)?;
91 Ok(())
92}
93
94pub fn remove_remote(maybe_config: Result<Config, AppError>, name: &str, remote_name: String) -> Result<(), AppError> {
95 let config: Config = maybe_config?;

Callers 1

_mainFunction · 0.85

Calls 1

write_projectFunction · 0.85

Tested by

no test coverage detected