@@ -11,7 +11,7 @@ use std::{
1111 rc:: { Rc , Weak } ,
1212} ;
1313
14- use anyhow:: Result ;
14+ use anyhow:: { bail , Result } ;
1515pub use kind:: * ;
1616pub use source_tree:: * ;
1717use tap:: Pipe ;
@@ -125,7 +125,7 @@ impl PBXFSReference {
125125 }
126126
127127 /// Returns a file path to current fs reference using source root.
128- pub fn full_path < P : AsRef < Path > > ( & self , source_root : P ) -> Result < Option < PathBuf > > {
128+ pub fn full_path < P : AsRef < Path > > ( & self , source_root : P ) -> Result < PathBuf > {
129129 let source_root = source_root. as_ref ( ) ;
130130
131131 let path = || {
@@ -142,22 +142,20 @@ impl PBXFSReference {
142142 }
143143
144144 match self . source_tree ( ) {
145- Some ( PBXSourceTree :: Absolute ) => path ( ) ?. pipe ( PathBuf :: from) . pipe ( Some ) ,
145+ Some ( PBXSourceTree :: Absolute ) => path ( ) ?. pipe ( PathBuf :: from) ,
146146 Some ( PBXSourceTree :: SourceRoot ) => {
147147 let mut root = source_root. to_path_buf ( ) ;
148148 root. extend ( get_parts ( path ( ) ?) ) ;
149- Some ( root)
149+ root
150150 }
151151 Some ( PBXSourceTree :: Group ) => {
152- let mut group_path: Option < PathBuf > ;
152+ let mut group_path: PathBuf ;
153153
154154 if let Some ( parent) = self . parent ( ) {
155155 println ! ( "Using parent path" ) ;
156156 group_path = parent. borrow ( ) . full_path ( & source_root) ?;
157- if let Some ( ref mut g) = group_path {
158- if let Some ( path) = self . path ( ) {
159- g. extend ( get_parts ( path) )
160- }
157+ if let Some ( path) = self . path ( ) {
158+ group_path. extend ( get_parts ( path) )
161159 }
162160 } else {
163161 let objects = self
@@ -177,10 +175,10 @@ impl PBXFSReference {
177175 let mut root = source_root. to_path_buf ( ) ;
178176 root. extend ( get_parts ( path) ) ;
179177 println ! ( "Joining {source_root:?} with {path:?}" ) ;
180- return Ok ( Some ( root) ) ;
178+ return Ok ( root) ;
181179 } else {
182180 println ! ( "Self is main group and return source_root as is!" ) ;
183- return Ok ( Some ( source_root. to_path_buf ( ) ) ) ;
181+ return Ok ( source_root. to_path_buf ( ) ) ;
184182 }
185183 }
186184
@@ -208,7 +206,9 @@ impl PBXFSReference {
208206 }
209207 group_path
210208 }
211- _ => None ,
209+ _ => {
210+ bail ! ( "Can't get full_path from {:#?}" , self )
211+ }
212212 }
213213 . pipe ( Ok )
214214 }
@@ -284,7 +284,7 @@ mod tests {
284284 let root = PathBuf :: from ( "/path/to/project" ) ;
285285 let main_group = main_group. borrow ( ) ;
286286 let main_group_full_path = main_group. full_path ( & root) ;
287- assert_eq ! ( main_group_full_path. unwrap( ) . unwrap ( ) , root) ;
287+ assert_eq ! ( main_group_full_path. unwrap( ) , root) ;
288288 }
289289
290290 #[ test]
@@ -302,10 +302,7 @@ mod tests {
302302
303303 let source_group = source_group. borrow ( ) ;
304304 let source_group_full_path = source_group. full_path ( & root) ;
305- assert_eq ! (
306- source_group_full_path. unwrap( ) . unwrap( ) ,
307- root. join( "Source" )
308- ) ;
305+ assert_eq ! ( source_group_full_path. unwrap( ) , root. join( "Source" ) ) ;
309306 }
310307
311308 #[ test]
@@ -330,6 +327,6 @@ mod tests {
330327
331328 let file = file. borrow ( ) ;
332329
333- assert_eq ! ( file. full_path( root) . unwrap( ) . unwrap ( ) , expected_file_path)
330+ assert_eq ! ( file. full_path( root) . unwrap( ) , expected_file_path)
334331 }
335332}
0 commit comments