diff --git a/asyncgit/src/sync/commit_files.rs b/asyncgit/src/sync/commit_files.rs index d3a80dca..a3f61939 100644 --- a/asyncgit/src/sync/commit_files.rs +++ b/asyncgit/src/sync/commit_files.rs @@ -71,7 +71,11 @@ pub(crate) fn get_commit_diff( mod tests { use super::get_commit_files; use crate::{ - sync::{commit, stage_add_file, tests::repo_init, CommitId}, + error::Result, + sync::{ + commit, stage_add_file, stash_save, tests::repo_init, + CommitId, + }, StatusItemType, }; use std::{fs::File, io::Write, path::Path}; @@ -98,4 +102,27 @@ mod tests { assert_eq!(diff.len(), 1); assert_eq!(diff[0].status, StatusItemType::New); } + + #[test] + fn test_stashed_untracked() -> Result<()> { + let file_path = Path::new("file1.txt"); + let (_td, repo) = repo_init().unwrap(); + let root = repo.path().parent().unwrap(); + let repo_path = root.as_os_str().to_str().unwrap(); + + File::create(&root.join(file_path))? + .write_all(b"test file1 content")?; + + let id = stash_save(repo_path, None, true, false)?; + + //TODO: https://github.com/extrawurst/gitui/issues/130 + // `get_commit_diff` actually needs to merge the regular diff + // and a third parent diff containing the untracked files + let _diff = get_commit_files(repo_path, id)?; + + // assert_eq!(diff.len(), 1); + // assert_eq!(diff[0].status, StatusItemType::New); + + Ok(()) + } } diff --git a/asyncgit/src/sync/stash.rs b/asyncgit/src/sync/stash.rs index f856b105..431f4a62 100644 --- a/asyncgit/src/sync/stash.rs +++ b/asyncgit/src/sync/stash.rs @@ -74,7 +74,7 @@ pub fn stash_save( message: Option<&str>, include_untracked: bool, keep_index: bool, -) -> Result<()> { +) -> Result { scope_time!("stash_save"); let mut repo = repo(repo_path)?; @@ -90,9 +90,9 @@ pub fn stash_save( options.insert(StashFlags::KEEP_INDEX) } - repo.stash_save2(&sig, message, Some(options))?; + let id = repo.stash_save2(&sig, message, Some(options))?; - Ok(()) + Ok(CommitId::new(id)) } #[cfg(test)] diff --git a/src/components/stashmsg.rs b/src/components/stashmsg.rs index a6350887..e5339037 100644 --- a/src/components/stashmsg.rs +++ b/src/components/stashmsg.rs @@ -66,7 +66,7 @@ impl Component for StashMsgComponent { self.options.stash_untracked, self.options.keep_index, ) { - Ok(()) => { + Ok(_) => { self.input.clear(); self.hide();