Execute stash push (save changes).
(
&self,
repo: &mut Repository,
message: Option<String>,
include_untracked: bool,
keep: bool,
)
| 268 | |
| 269 | /// Execute stash push (save changes). |
| 270 | fn run_push( |
| 271 | &self, |
| 272 | repo: &mut Repository, |
| 273 | message: Option<String>, |
| 274 | include_untracked: bool, |
| 275 | keep: bool, |
| 276 | ) -> CliResult<()> { |
| 277 | // The domain owns the flow (status check, orphan view, raw-bytes |
| 278 | // sidecar, materialize); this is the presentation half. |
| 279 | let options = StashPushOptions { |
| 280 | message: message.or_else(|| self.message.clone()), |
| 281 | include_untracked: include_untracked || self.include_untracked, |
| 282 | keep: keep || self.keep, |
| 283 | }; |
| 284 | match repo |
| 285 | .stash_push(options) |
| 286 | .map_err(|message| CliError::Internal(anyhow::anyhow!(message)))? |
| 287 | { |
| 288 | None => { |
| 289 | print_warning("No local changes to save"); |
| 290 | } |
| 291 | Some(entry) => { |
| 292 | // Recompute the display reference from the listing (the |
| 293 | // entry's index is assigned by stash_list). |
| 294 | let stash_ref = repo |
| 295 | .stash_list() |
| 296 | .map_err(|message| CliError::Internal(anyhow::anyhow!(message)))? |
| 297 | .iter() |
| 298 | .find(|s| s.view_name == entry.view_name) |
| 299 | .map(|s| s.reference()) |
| 300 | .unwrap_or_else(|| "stash@{0}".to_string()); |
| 301 | print_success(&format!("Saved working copy to {stash_ref}")); |
| 302 | if !keep && !self.keep { |
| 303 | print_success("Working copy restored to clean state"); |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | Ok(()) |
| 308 | } |
| 309 | |
| 310 | /// Execute stash pop (apply and delete). |
| 311 | fn run_pop(&self, repo: &mut Repository, stash_ref: Option<&str>) -> CliResult<()> { |
no test coverage detected