@@ -1272,3 +1272,70 @@ rustdns.workspace = true
1272
1272
)
1273
1273
. run ( ) ;
1274
1274
}
1275
+
1276
+ #[ cargo_test]
1277
+ fn update_precise_git_revisions ( ) {
1278
+ let ( git_project, git_repo) = git:: new_repo ( "git" , |p| {
1279
+ p. file ( "Cargo.toml" , & basic_lib_manifest ( "git" ) )
1280
+ . file ( "src/lib.rs" , "" )
1281
+ } ) ;
1282
+ let tag_name = "Nazgûl" ;
1283
+ git:: tag ( & git_repo, tag_name) ;
1284
+
1285
+ git_project. change_file ( "src/lib.rs" , "fn f() {}" ) ;
1286
+ git:: add ( & git_repo) ;
1287
+ let head_id = git:: commit ( & git_repo) . to_string ( ) ;
1288
+ let short_id = & head_id[ ..8 ] ;
1289
+ let url = git_project. url ( ) ;
1290
+
1291
+ let p = project ( )
1292
+ . file (
1293
+ "Cargo.toml" ,
1294
+ & format ! (
1295
+ r#"
1296
+ [package]
1297
+ name = "foo"
1298
+ version = "0.1.0"
1299
+
1300
+ [dependencies]
1301
+ git = {{ git = '{url}' }}
1302
+ "#
1303
+ ) ,
1304
+ )
1305
+ . file ( "src/lib.rs" , "" )
1306
+ . build ( ) ;
1307
+
1308
+ p. cargo ( "fetch" )
1309
+ . with_stderr ( format ! ( "[UPDATING] git repository `{url}`" ) )
1310
+ . run ( ) ;
1311
+
1312
+ assert ! ( p. read_lockfile( ) . contains( & head_id) ) ;
1313
+
1314
+ p. cargo ( "update git --precise" )
1315
+ . arg ( tag_name)
1316
+ . with_status ( 101 )
1317
+ . with_stderr ( format ! (
1318
+ "\
1319
+ [ERROR] Unable to update {url}#{tag_name}
1320
+
1321
+ Caused by:
1322
+ precise value for git is not a git revision: {tag_name}
1323
+
1324
+ Caused by:
1325
+ [..]"
1326
+ ) )
1327
+ . run ( ) ;
1328
+
1329
+ p. cargo ( "update git --precise" )
1330
+ . arg ( short_id)
1331
+ . with_status ( 101 )
1332
+ . with_stderr ( format ! (
1333
+ "\
1334
+ [UPDATING] git repository `{url}`
1335
+ [ERROR] Unable to update {url}#{short_id}
1336
+
1337
+ Caused by:
1338
+ object not found - no match for id ({short_id}00000000000000[..]); [..]" ,
1339
+ ) )
1340
+ . run ( ) ;
1341
+ }
0 commit comments