Update the URL of an existing remote. # Arguments `name` - The name of the remote to update `url` - The new URL # Errors Returns an error if the remote doesn't exist or the URL is invalid.
(&mut self, name: &str, url: impl Into<String>)
| 542 | /// |
| 543 | /// Returns an error if the remote doesn't exist or the URL is invalid. |
| 544 | pub fn set_url(&mut self, name: &str, url: impl Into<String>) -> RemoteResult<()> { |
| 545 | let url = url.into(); |
| 546 | |
| 547 | // Validate URL |
| 548 | if !url.contains("://") { |
| 549 | return Err(RemoteError::InvalidUrl { |
| 550 | url, |
| 551 | reason: "URL must include a scheme (e.g., https://)".to_string(), |
| 552 | }); |
| 553 | } |
| 554 | |
| 555 | let entry = self |
| 556 | .remotes |
| 557 | .get_mut(name) |
| 558 | .ok_or_else(|| RemoteError::NotFound { |
| 559 | name: name.to_string(), |
| 560 | })?; |
| 561 | |
| 562 | entry.url = url; |
| 563 | Ok(()) |
| 564 | } |
| 565 | |
| 566 | /// Set a remote as the default. |
| 567 | /// |