@@ -197,7 +197,10 @@ impl Repository {
197
197
/// - If reading the global git config fails.
198
198
///
199
199
pub fn open ( repository_config : & RepositoryConfig ) -> anyhow:: Result < Self > {
200
- let checkout_path = tempfile:: Builder :: new ( ) . prefix ( "git" ) . tempdir ( ) ?;
200
+ let checkout_path = tempfile:: Builder :: new ( )
201
+ . prefix ( "git" )
202
+ . tempdir ( )
203
+ . context ( "Failed to create temporary directory" ) ?;
201
204
202
205
let repository = git2:: build:: RepoBuilder :: new ( )
203
206
. fetch_options ( Self :: fetch_options ( & repository_config. credentials ) )
@@ -212,13 +215,21 @@ impl Repository {
212
215
. clone (
213
216
repository_config. index_location . as_str ( ) ,
214
217
checkout_path. path ( ) ,
215
- ) ?;
218
+ )
219
+ . context ( "Failed to clone index repository" ) ?;
216
220
217
221
// All commits to the index registry made through crates.io will be made by bors, the Rust
218
222
// community's friendly GitHub bot.
219
- let mut cfg = repository. config ( ) ?;
220
- cfg. set_str ( "user.name" , "bors" ) ?;
221
- cfg
. set_str ( "user.email" , "[email protected] " ) ?
;
223
+
224
+ let mut cfg = repository
225
+ . config ( )
226
+ . context ( "Failed to read git configuration" ) ?;
227
+
228
+ cfg. set_str ( "user.name" , "bors" )
229
+ . context ( "Failed to set user name" ) ?;
230
+
231
+ cfg
. set_str ( "user.email" , "[email protected] " )
232
+ . context ( "Failed to set user email address" ) ?;
222
233
223
234
Ok ( Self {
224
235
checkout_path,
@@ -260,7 +271,9 @@ impl Repository {
260
271
/// - If the `HEAD` pointer can't be retrieved.
261
272
///
262
273
pub fn head_oid ( & self ) -> anyhow:: Result < git2:: Oid > {
263
- Ok ( self . repository . head ( ) ?. target ( ) . unwrap ( ) )
274
+ let repo = & self . repository ;
275
+ let head = repo. head ( ) . context ( "Failed to read HEAD reference" ) ?;
276
+ Ok ( head. target ( ) . unwrap ( ) )
264
277
}
265
278
266
279
/// Commits the specified file with the specified commit message and pushes
0 commit comments