@@ -78,7 +78,11 @@ mod apply {
7878 "$ID$ case sensitive matching" ,
7979 "$Id: expanded is ignored$" ,
8080 ] {
81- let changed = ident:: apply ( input_no_match. as_bytes ( ) , gix_hash:: Kind :: Sha1 , & mut buf) ?;
81+ let changed = ident:: apply (
82+ input_no_match. as_bytes ( ) ,
83+ gix_testtools:: hash_kind_from_env ( ) . unwrap_or_default ( ) ,
84+ & mut buf,
85+ ) ?;
8286 assert ! ( !changed, "no substitution happens, nothing to do" ) ;
8387 assert_eq ! ( buf. len( ) , 0 ) ;
8488 }
@@ -89,15 +93,33 @@ mod apply {
8993 fn simple ( ) -> crate :: Result {
9094 let mut buf = Vec :: new ( ) ;
9195 assert ! (
92- ident:: apply( B ( "$Id$" ) , gix_hash:: Kind :: Sha1 , & mut buf) ?,
96+ ident:: apply(
97+ B ( "$Id$" ) ,
98+ gix_testtools:: hash_kind_from_env( ) . unwrap_or_default( ) ,
99+ & mut buf
100+ ) ?,
93101 "a change happens"
94102 ) ;
95- assert_eq ! ( buf. as_bstr( ) , "$Id: b3f5ebfb5843bc43ceecff6d4f26bb37c615beb1$" ) ;
103+ let expected_hash = match gix_testtools:: hash_kind_from_env ( ) . unwrap_or_default ( ) {
104+ gix_hash:: Kind :: Sha1 => "b3f5ebfb5843bc43ceecff6d4f26bb37c615beb1" ,
105+ gix_hash:: Kind :: Sha256 => "63cdf77e7872965e2af1bee42e925f9b4bd6a3ab9f5ef6c06c4312f7d90d8021" ,
106+ _ => unimplemented ! ( ) ,
107+ } ;
108+ assert_eq ! ( buf. as_bstr( ) , format!( "$Id: {expected_hash}$" ) ) ;
96109
97- assert ! ( ident:: apply( B ( "$Id$ $Id$ foo" ) , gix_hash:: Kind :: Sha1 , & mut buf) ?) ;
110+ assert ! ( ident:: apply(
111+ B ( "$Id$ $Id$ foo" ) ,
112+ gix_testtools:: hash_kind_from_env( ) . unwrap_or_default( ) ,
113+ & mut buf
114+ ) ?) ;
115+ let expected_hash = match gix_testtools:: hash_kind_from_env ( ) . unwrap_or_default ( ) {
116+ gix_hash:: Kind :: Sha1 => "e230cff7a9624f59eaa28bfb97602c3a03651a49" ,
117+ gix_hash:: Kind :: Sha256 => "64a29d2cfd88cf6cfd786cdd88e99112bef2f7d8596a8701f6955784624604ca" ,
118+ _ => unimplemented ! ( ) ,
119+ } ;
98120 assert_eq ! (
99121 buf. as_bstr( ) ,
100- "$Id: e230cff7a9624f59eaa28bfb97602c3a03651a49 $ $Id: e230cff7a9624f59eaa28bfb97602c3a03651a49 $ foo"
122+ format! ( "$Id: {expected_hash} $ $Id: {expected_hash} $ foo" )
101123 ) ;
102124 Ok ( ( ) )
103125 }
@@ -110,7 +132,11 @@ mod apply {
110132 "$Id$" ,
111133 "$Id$ and one more $Id$ and done" ,
112134 ] {
113- let changed = ident:: apply ( B ( input) , gix_hash:: Kind :: Sha1 , & mut buf) ?;
135+ let changed = ident:: apply (
136+ B ( input) ,
137+ gix_testtools:: hash_kind_from_env ( ) . unwrap_or_default ( ) ,
138+ & mut buf,
139+ ) ?;
114140 assert ! ( changed, "the input was rewritten" ) ;
115141 assert ! ( ident:: undo( & buf. clone( ) , & mut buf) ?, "undo does something as well" ) ;
116142 assert_eq ! ( buf. as_bstr( ) , input, "the filter can be undone perfectly" ) ;
0 commit comments