Add stash apply action
This commit is contained in:
parent
4a11d9d4c6
commit
775425e8c7
10 changed files with 180 additions and 6 deletions
|
@ -60,6 +60,8 @@ actions!(
|
|||
StashAll,
|
||||
/// Pops the most recent stash.
|
||||
StashPop,
|
||||
/// Apply the most recent stash.
|
||||
StashApply,
|
||||
/// Restores all tracked files to their last committed state.
|
||||
RestoreTrackedFiles,
|
||||
/// Moves all untracked files to trash.
|
||||
|
|
|
@ -408,6 +408,12 @@ pub trait GitRepository: Send + Sync {
|
|||
env: Arc<HashMap<String, String>>,
|
||||
) -> BoxFuture<'_, Result<()>>;
|
||||
|
||||
fn stash_apply(
|
||||
&self,
|
||||
index: Option<usize>,
|
||||
env: Arc<HashMap<String, String>>,
|
||||
) -> BoxFuture<'_, Result<()>>;
|
||||
|
||||
fn stash_drop(
|
||||
&self,
|
||||
index: Option<usize>,
|
||||
|
@ -1289,6 +1295,35 @@ impl GitRepository for RealGitRepository {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn stash_apply(
|
||||
&self,
|
||||
index: Option<usize>,
|
||||
env: Arc<HashMap<String, String>>,
|
||||
) -> BoxFuture<'_, Result<()>> {
|
||||
let working_directory = self.working_directory();
|
||||
self.executor
|
||||
.spawn(async move {
|
||||
let mut cmd = new_smol_command("git");
|
||||
let mut args = vec!["stash".to_string(), "apply".to_string()];
|
||||
if let Some(index) = index {
|
||||
args.push(format!("stash@{{{}}}", index));
|
||||
}
|
||||
cmd.current_dir(&working_directory?)
|
||||
.envs(env.iter())
|
||||
.args(args);
|
||||
|
||||
let output = cmd.output().await?;
|
||||
|
||||
anyhow::ensure!(
|
||||
output.status.success(),
|
||||
"Failed to apply stash:\n{}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
Ok(())
|
||||
})
|
||||
.boxed()
|
||||
}
|
||||
|
||||
fn stash_drop(
|
||||
&self,
|
||||
index: Option<usize>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue