Execute the stash command.
(&self)
| 723 | impl Command for Stash { |
| 724 | /// Execute the stash command. |
| 725 | fn run(&self) -> CliResult<()> { |
| 726 | // Find repository |
| 727 | let repo_root = find_repository_root()?; |
| 728 | let mut repo = Repository::open(&repo_root).map_err(CliError::Repository)?; |
| 729 | |
| 730 | match &self.command { |
| 731 | None => { |
| 732 | // Default action: push |
| 733 | self.run_push(&mut repo, None, self.include_untracked, self.keep) |
| 734 | } |
| 735 | Some(StashSubcommand::Push { |
| 736 | message, |
| 737 | include_untracked, |
| 738 | keep, |
| 739 | }) => self.run_push(&mut repo, message.clone(), *include_untracked, *keep), |
| 740 | Some(StashSubcommand::Pop { stash }) => self.run_pop(&mut repo, stash.as_deref()), |
| 741 | Some(StashSubcommand::Apply { stash }) => self.run_apply(&mut repo, stash.as_deref()), |
| 742 | Some(StashSubcommand::List) => self.run_list(&repo), |
| 743 | Some(StashSubcommand::Show { stash, patch }) => { |
| 744 | self.run_show(&repo, stash.as_deref(), *patch) |
| 745 | } |
| 746 | Some(StashSubcommand::Drop { stash }) => self.run_drop(&mut repo, stash.as_deref()), |
| 747 | Some(StashSubcommand::Clear { force }) => self.run_clear(&mut repo, *force), |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | // Tests |