File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed
Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -164,17 +164,14 @@ impl GitManager {
164164
165165 fn get_repository ( & self ) -> Result < Repository > {
166166 let path = PathBuf :: from ( UPLOAD_DIR ) . join ( self . problem_id . to_string ( ) ) ;
167- if let Ok ( repo) = Repository :: open ( & path) {
168- let mut config = repo. config ( ) ?;
169- config. set_str ( "user.name" , "admin" ) ?;
170- config
. set_str ( "user.email" , "[email protected] " ) ?
; 171- Ok ( repo)
172- } else {
173- Err ( anyhow:: anyhow!(
174- "Failed to open git repository at {:?}" ,
175- path
176- ) )
177- }
167+ Repository :: open ( & path)
168+ . with_context ( || format ! ( "Failed to open git repository at {:?}" , path) )
169+ . and_then ( |repo| {
170+ let mut config = repo. config ( ) ?;
171+ config. set_str ( "user.name" , "admin" ) ?;
172+ config
. set_str ( "user.email" , "[email protected] " ) ?
; 173+ Ok ( repo)
174+ } )
178175 }
179176}
180177
You can’t perform that action at this time.
0 commit comments