(
&self,
request: Request<CreateStashRequest>,
)
| 2781 | } |
| 2782 | |
| 2783 | async fn create_stash( |
| 2784 | &self, |
| 2785 | request: Request<CreateStashRequest>, |
| 2786 | ) -> Result<Response<CreateStashResponse>, Status> { |
| 2787 | let request = request.into_inner(); |
| 2788 | let handle = self |
| 2789 | .state |
| 2790 | .resolve(request.repository.as_ref().unwrap_or(&default_ref()))?; |
| 2791 | self.state.log_rpc("CreateStash", Some(&handle)); |
| 2792 | let gate_handle = handle.clone(); |
| 2793 | let _gate = gate_handle.exclusive().await; |
| 2794 | let result = tokio::task::spawn_blocking(move || -> Result<CreateStashResponse, Status> { |
| 2795 | let (mut repo, _workspace) = |
| 2796 | handle.workspace_repository(atomic_repository::WorkspaceTxnMode::Reconcile)?; |
| 2797 | match repo |
| 2798 | .stash_push(atomic_repository::StashPushOptions { |
| 2799 | message: request.message, |
| 2800 | include_untracked: request.include_untracked, |
| 2801 | keep: request.keep, |
| 2802 | }) |
| 2803 | .map_err(|message| domain_status(ErrorCode::Repository, message))? |
| 2804 | { |
| 2805 | // A clean working copy is Ok(None), never an error — |
| 2806 | // the empty stash_id says "nothing to save". |
| 2807 | None => Ok(CreateStashResponse { |
| 2808 | stash_id: String::new(), |
| 2809 | meta: None, |
| 2810 | }), |
| 2811 | Some(entry) => Ok(CreateStashResponse { |
| 2812 | stash_id: entry.view_name, |
| 2813 | meta: None, |
| 2814 | }), |
| 2815 | } |
| 2816 | }) |
| 2817 | .await |
| 2818 | .map_err(|error| Status::internal(format!("stash task failed: {error}")))??; |
| 2819 | Ok(Response::new(result)) |
| 2820 | } |
| 2821 | |
| 2822 | async fn apply_stash( |
| 2823 | &self, |
nothing calls this directly
no test coverage detected