summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConcelare <113200622+Concelare@users.noreply.github.com>2024-03-26 15:50:13 +0000
committerGitHub <noreply@github.com>2024-03-26 15:50:13 +0000
commit92e0face1e5d29d1d87e1a334efeb4c663cd0767 (patch)
tree7c1a84c26ea209bfd4fd5fd2e7dfa31aa8f4347e
parent8272b20913372a4d5792b6f5edfce17107cef8ef (diff)
add tests for commitChar filtering (#2151)
adds missing tests for b15c8643c8692fc9f01508120709e12d50d8e26a (see #2145)
-rw-r--r--asyncgit/src/sync/commit.rs39
1 files changed, 38 insertions, 1 deletions
diff --git a/asyncgit/src/sync/commit.rs b/asyncgit/src/sync/commit.rs
index 903dbcca..0792aa21 100644
--- a/asyncgit/src/sync/commit.rs
+++ b/asyncgit/src/sync/commit.rs
@@ -211,7 +211,7 @@ mod tests {
utils::get_head,
LogWalker,
};
- use commit::{amend, tag_commit};
+ use commit::{amend, commit_message_prettify, tag_commit};
use git2::Repository;
use std::{fs::File, io::Write, path::Path};
@@ -463,4 +463,41 @@ mod tests {
Ok(())
}
+
+ #[test]
+ fn test_empty_comment_char() -> Result<()> {
+ let (_td, repo) = repo_init_empty().unwrap();
+
+ let root = repo.path().parent().unwrap();
+ let repo_path: &RepoPath =
+ &root.as_os_str().to_str().unwrap().into();
+
+ let message = commit_message_prettify(
+ repo_path,
+ "#This is a test message\nTest".to_owned(),
+ )?;
+
+ assert_eq!(message, "Test\n");
+ Ok(())
+ }
+
+ #[test]
+ fn test_with_comment_char() -> Result<()> {
+ let (_td, repo) = repo_init_empty().unwrap();
+
+ let root = repo.path().parent().unwrap();
+ let repo_path: &RepoPath =
+ &root.as_os_str().to_str().unwrap().into();
+
+ repo.config()?.set_str("core.commentChar", ";")?;
+
+ let message = commit_message_prettify(
+ repo_path,
+ ";This is a test message\nTest".to_owned(),
+ )?;
+
+ assert_eq!(message, "Test\n");
+
+ Ok(())
+ }
}