@@ -80,6 +80,8 @@ fn main() {
8080 let main_dir = self_dir. join ( "../../../.." ) ;
8181 std:: env:: set_current_dir ( main_dir) . unwrap ( ) ;
8282
83+ let args: Args = argh:: from_env ( ) ;
84+
8385 let version_locs = vec ! [
8486 Location :: new(
8587 "Cargo.toml" ,
@@ -103,24 +105,23 @@ fn main() {
103105 r#"html_root_url = "https://docs.rs/mongodb/(?<target>.*?)""# ,
104106 ) ,
105107 ] ;
106- let bson_version_loc = Location :: new ( "Cargo.toml" , r#"bson = (?<target>\{ git = .*? \})\n"# ) ;
107- let mongocrypt_version_loc =
108- Location :: new ( "Cargo.toml" , r#"mongocrypt = (?<target>\{ git = .*? \})\n"# ) ;
109-
110- let args: Args = argh:: from_env ( ) ;
111-
112108 let mut pending = PendingUpdates :: new ( ) ;
113109 for loc in & version_locs {
114110 pending. apply ( loc, & args. version ) ;
115111 }
112+
116113 if let Some ( bson) = args. bson {
117- pending. apply ( & bson_version_loc, & format ! ( "{:?}" , bson) ) ;
114+ let bson_version_loc =
115+ Location :: new ( "Cargo.toml" , r#"bson =.*version = "(?<target>.*?)".*"# ) ;
116+ pending. apply ( & bson_version_loc, & bson) ;
118117 }
118+
119119 if let Some ( mongocrypt) = args. mongocrypt {
120- pending . apply (
121- & mongocrypt_version_loc ,
122- & format ! ( "{{ version = {:?}, optional = true }}" , mongocrypt ) ,
120+ let mongocrypt_version_loc = Location :: new (
121+ "Cargo.toml" ,
122+ r#"mongocrypt =.* version = "(?<target>.*?)".*"# ,
123123 ) ;
124+ pending. apply ( & mongocrypt_version_loc, & mongocrypt) ;
124125 }
125126 pending. write ( ) ;
126127}
0 commit comments