File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -1049,6 +1049,19 @@ pub enum FileMode {
1049
1049
Commit ,
1050
1050
}
1051
1051
1052
+ impl From < FileMode > for u32 {
1053
+ fn from ( mode : FileMode ) -> u32 {
1054
+ match mode {
1055
+ FileMode :: Unreadable => raw:: GIT_FILEMODE_UNREADABLE as u32 ,
1056
+ FileMode :: Tree => raw:: GIT_FILEMODE_TREE as u32 ,
1057
+ FileMode :: Blob => raw:: GIT_FILEMODE_BLOB as u32 ,
1058
+ FileMode :: BlobExecutable => raw:: GIT_FILEMODE_BLOB_EXECUTABLE as u32 ,
1059
+ FileMode :: Link => raw:: GIT_FILEMODE_LINK as u32 ,
1060
+ FileMode :: Commit => raw:: GIT_FILEMODE_COMMIT as u32 ,
1061
+ }
1062
+ }
1063
+ }
1064
+
1052
1065
bitflags ! {
1053
1066
/// Return codes for submodule status.
1054
1067
///
@@ -1441,12 +1454,18 @@ impl Default for ReferenceFormat {
1441
1454
1442
1455
#[ cfg( test) ]
1443
1456
mod tests {
1444
- use super :: ObjectType ;
1457
+ use super :: { FileMode , ObjectType } ;
1445
1458
1446
1459
#[ test]
1447
1460
fn convert ( ) {
1448
1461
assert_eq ! ( ObjectType :: Blob . str ( ) , "blob" ) ;
1449
1462
assert_eq ! ( ObjectType :: from_str( "blob" ) , Some ( ObjectType :: Blob ) ) ;
1450
1463
assert ! ( ObjectType :: Blob . is_loose( ) ) ;
1451
1464
}
1465
+
1466
+ #[ test]
1467
+ fn convert_filemode ( ) {
1468
+ assert_eq ! ( u32 :: from( FileMode :: Blob ) , 0o100644 ) ;
1469
+ assert_eq ! ( u32 :: from( FileMode :: BlobExecutable ) , 0o100755 ) ;
1470
+ }
1452
1471
}
You can’t perform that action at this time.
0 commit comments