File tree Expand file tree Collapse file tree 2 files changed +65
-1
lines changed Expand file tree Collapse file tree 2 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,16 @@ fn check_repo_state(
290
290
. filter ( |file| {
291
291
let relative = file. strip_prefix ( workdir) . unwrap ( ) ;
292
292
if let Ok ( status) = repo. status_file ( relative) {
293
- status != git2:: Status :: CURRENT
293
+ if status == git2:: Status :: CURRENT {
294
+ false
295
+ } else {
296
+ if relative. to_str ( ) . unwrap_or ( "" ) == "Cargo.lock" {
297
+ // It is OK to include this file even if it is ignored.
298
+ status != git2:: Status :: IGNORED
299
+ } else {
300
+ true
301
+ }
302
+ }
294
303
} else {
295
304
submodule_dirty ( file)
296
305
}
Original file line number Diff line number Diff line change @@ -396,3 +396,58 @@ dependencies = [
396
396
)
397
397
. run ( ) ;
398
398
}
399
+
400
+ #[ cargo_test]
401
+ fn ignore_lockfile ( ) {
402
+ // With an explicit `include` list, but Cargo.lock in .gitignore, don't
403
+ // complain about `Cargo.lock` being ignored. Note that it is still
404
+ // included in the packaged regardless.
405
+ let ( p, _r) = git:: new_repo ( "foo" , |p| {
406
+ p. file (
407
+ "Cargo.toml" ,
408
+ r#"
409
+ [package]
410
+ name = "foo"
411
+ version = "0.0.1"
412
+ authors = []
413
+ license = "MIT"
414
+ description = "foo"
415
+ documentation = "foo"
416
+ homepage = "foo"
417
+ repository = "foo"
418
+
419
+ include = [
420
+ "src/main.rs"
421
+ ]
422
+ "# ,
423
+ )
424
+ . file ( "src/main.rs" , "fn main() {}" )
425
+ . file ( ".gitignore" , "Cargo.lock" )
426
+ } ) ;
427
+ p. cargo ( "package -l" )
428
+ . with_stdout (
429
+ "\
430
+ .cargo_vcs_info.json
431
+ Cargo.lock
432
+ Cargo.toml
433
+ src/main.rs
434
+ " ,
435
+ )
436
+ . run ( ) ;
437
+ p. cargo ( "generate-lockfile" ) . run ( ) ;
438
+ p. cargo ( "package -v" )
439
+ . with_stderr (
440
+ "\
441
+ [PACKAGING] foo v0.0.1 ([..])
442
+ [ARCHIVING] Cargo.toml
443
+ [ARCHIVING] src/main.rs
444
+ [ARCHIVING] .cargo_vcs_info.json
445
+ [ARCHIVING] Cargo.lock
446
+ [VERIFYING] foo v0.0.1 ([..])
447
+ [COMPILING] foo v0.0.1 ([..])
448
+ [RUNNING] `rustc --crate-name foo src/main.rs [..]
449
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
450
+ " ,
451
+ )
452
+ . run ( ) ;
453
+ }
You can’t perform that action at this time.
0 commit comments