Expand a leading `~` in a destination path.
(dst: &str)
| 549 | |
| 550 | /// Expand a leading `~` in a destination path. |
| 551 | fn expand_dst(dst: &str) -> AgentResult<PathBuf> { |
| 552 | if dst == "~" { |
| 553 | return dirs::home_dir().ok_or_else(|| AgentError::Integration { |
| 554 | agent: "<any>".to_string(), |
| 555 | reason: "cannot resolve home directory".to_string(), |
| 556 | }); |
| 557 | } |
| 558 | if let Some(rest) = dst.strip_prefix("~/") { |
| 559 | return dirs::home_dir() |
| 560 | .map(|h| h.join(rest)) |
| 561 | .ok_or_else(|| AgentError::Integration { |
| 562 | agent: "<any>".to_string(), |
| 563 | reason: "cannot resolve home directory".to_string(), |
| 564 | }); |
| 565 | } |
| 566 | Ok(PathBuf::from(dst)) |
| 567 | } |
| 568 | |
| 569 | /// Resolve a `[[repo-file]]` destination against the repository root. |
| 570 | /// `dst` must be a relative path (no `~`, no absolute) — it lands inside the |