File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
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 i32 {
1053
+ fn from ( mode : FileMode ) -> i32 {
1054
+ match mode {
1055
+ FileMode :: Unreadable => raw:: GIT_FILEMODE_UNREADABLE as i32 ,
1056
+ FileMode :: Tree => raw:: GIT_FILEMODE_TREE as i32 ,
1057
+ FileMode :: Blob => raw:: GIT_FILEMODE_BLOB as i32 ,
1058
+ FileMode :: BlobExecutable => raw:: GIT_FILEMODE_BLOB_EXECUTABLE as i32 ,
1059
+ FileMode :: Link => raw:: GIT_FILEMODE_LINK as i32 ,
1060
+ FileMode :: Commit => raw:: GIT_FILEMODE_COMMIT as i32 ,
1061
+ }
1062
+ }
1063
+ }
1064
+
1052
1065
impl From < FileMode > for u32 {
1053
1066
fn from ( mode : FileMode ) -> u32 {
1054
1067
match mode {
@@ -1465,6 +1478,8 @@ mod tests {
1465
1478
1466
1479
#[ test]
1467
1480
fn convert_filemode ( ) {
1481
+ assert_eq ! ( i32 :: from( FileMode :: Blob ) , 0o100644 ) ;
1482
+ assert_eq ! ( i32 :: from( FileMode :: BlobExecutable ) , 0o100755 ) ;
1468
1483
assert_eq ! ( u32 :: from( FileMode :: Blob ) , 0o100644 ) ;
1469
1484
assert_eq ! ( u32 :: from( FileMode :: BlobExecutable ) , 0o100755 ) ;
1470
1485
}
You can’t perform that action at this time.
0 commit comments