Commit 9a62523 1 parent 0d522da commit 9a62523 Copy full SHA for 9a62523
File tree 3 files changed +35
-18
lines changed
3 files changed +35
-18
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ resolver = "2"
24
24
25
25
[workspace .package ]
26
26
license = " MIT"
27
- version = " 0. 1.0"
27
+ version = " 1.0.0-rc1 "
28
28
29
29
[workspace .dependencies ]
30
30
anyhow = " 1.0"
Original file line number Diff line number Diff line change @@ -93,6 +93,8 @@ pub enum CommitValidationError {
93
93
StorageError ( #[ from] StorageError ) ,
94
94
#[ error( "Exceeded max characters for this field. Must be under: {length}" ) ]
95
95
TooManyCharacters { length : usize } ,
96
+ #[ error( "Version part missing" ) ]
97
+ VersionMissing ,
96
98
}
97
99
98
100
impl RetryableError for CommitValidationError {
@@ -224,6 +226,7 @@ pub struct LibXMTPVersion {
224
226
major : u32 ,
225
227
minor : u32 ,
226
228
patch : u32 ,
229
+ suffix : Option < String > ,
227
230
}
228
231
229
232
impl LibXMTPVersion {
@@ -235,20 +238,34 @@ impl LibXMTPVersion {
235
238
) ) ;
236
239
}
237
240
238
- let major = parts[ 0 ]
241
+ let major = parts
242
+ . first ( )
243
+ . ok_or ( CommitValidationError :: VersionMissing ) ?
239
244
. parse ( )
240
245
. map_err ( |_| CommitValidationError :: InvalidVersionFormat ( version_str. to_string ( ) ) ) ?;
241
- let minor = parts[ 1 ]
246
+ let minor = parts
247
+ . get ( 1 )
248
+ . ok_or ( CommitValidationError :: VersionMissing ) ?
242
249
. parse ( )
243
250
. map_err ( |_| CommitValidationError :: InvalidVersionFormat ( version_str. to_string ( ) ) ) ?;
244
- let patch = parts[ 2 ]
251
+
252
+ let patch_and_suffix = parts
253
+ . get ( 2 )
254
+ . ok_or ( CommitValidationError :: VersionMissing ) ?
255
+ . split ( '-' )
256
+ . collect :: < Vec < _ > > ( ) ;
257
+
258
+ let patch = patch_and_suffix
259
+ . first ( )
260
+ . ok_or ( CommitValidationError :: VersionMissing ) ?
245
261
. parse ( )
246
262
. map_err ( |_| CommitValidationError :: InvalidVersionFormat ( version_str. to_string ( ) ) ) ?;
247
263
248
264
Ok ( LibXMTPVersion {
249
265
major,
250
266
minor,
251
267
patch,
268
+ suffix : patch_and_suffix. get ( 1 ) . map ( ToString :: to_string) ,
252
269
} )
253
270
}
254
271
}
You can’t perform that action at this time.
0 commit comments