Add a new remote.
(&self, add: &RemoteAdd)
| 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<()> { |
no test coverage detected