@@ -211,7 +211,7 @@ mod tests {
211211 utils:: get_head,
212212 LogWalker ,
213213 } ;
214- use commit:: { amend, tag_commit} ;
214+ use commit:: { amend, commit_message_prettify , tag_commit} ;
215215 use git2:: Repository ;
216216 use std:: { fs:: File , io:: Write , path:: Path } ;
217217
@@ -463,4 +463,41 @@ mod tests {
463463
464464 Ok ( ( ) )
465465 }
466+
467+ #[ test]
468+ fn test_empty_comment_char ( ) -> Result < ( ) > {
469+ let ( _td, repo) = repo_init_empty ( ) . unwrap ( ) ;
470+
471+ let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
472+ let repo_path: & RepoPath =
473+ & root. as_os_str ( ) . to_str ( ) . unwrap ( ) . into ( ) ;
474+
475+ let message = commit_message_prettify (
476+ repo_path,
477+ "#This is a test message\n Test" . to_owned ( ) ,
478+ ) ?;
479+
480+ assert_eq ! ( message, "Test\n " ) ;
481+ Ok ( ( ) )
482+ }
483+
484+ #[ test]
485+ fn test_with_comment_char ( ) -> Result < ( ) > {
486+ let ( _td, repo) = repo_init_empty ( ) . unwrap ( ) ;
487+
488+ let root = repo. path ( ) . parent ( ) . unwrap ( ) ;
489+ let repo_path: & RepoPath =
490+ & root. as_os_str ( ) . to_str ( ) . unwrap ( ) . into ( ) ;
491+
492+ repo. config ( ) ?. set_str ( "core.commentChar" , ";" ) ?;
493+
494+ let message = commit_message_prettify (
495+ repo_path,
496+ ";This is a test message\n Test" . to_owned ( ) ,
497+ ) ?;
498+
499+ assert_eq ! ( message, "Test\n " ) ;
500+
501+ Ok ( ( ) )
502+ }
466503}
0 commit comments