|
4 | 4 | //! "fake" crates.io is used. Otherwise `vendor` would download the crates.io
|
5 | 5 | //! index from the network.
|
6 | 6 |
|
| 7 | +use std::fs; |
| 8 | + |
7 | 9 | use cargo_test_support::git;
|
8 | 10 | use cargo_test_support::registry::Package;
|
9 |
| -use cargo_test_support::{basic_lib_manifest, project, Project}; |
| 11 | +use cargo_test_support::{basic_lib_manifest, paths, project, Project}; |
10 | 12 |
|
11 | 13 | #[cargo_test]
|
12 | 14 | fn vendor_simple() {
|
@@ -631,3 +633,45 @@ fn config_instructions_works() {
|
631 | 633 | .with_stderr_contains("[..]foo/vendor/gitdep/src/lib.rs[..]")
|
632 | 634 | .run();
|
633 | 635 | }
|
| 636 | + |
| 637 | +#[cargo_test] |
| 638 | +fn git_crlf_preservation() { |
| 639 | + // Check that newlines don't get changed when you vendor |
| 640 | + // (will only fail if your system is setup with core.autocrlf=true on windows) |
| 641 | + let input = "hello \nthere\nmy newline\nfriends"; |
| 642 | + let git_project = git::new("git", |p| { |
| 643 | + p.file("Cargo.toml", &basic_lib_manifest("a")) |
| 644 | + .file("src/lib.rs", input) |
| 645 | + }); |
| 646 | + |
| 647 | + let p = project() |
| 648 | + .file( |
| 649 | + "Cargo.toml", |
| 650 | + &format!( |
| 651 | + r#" |
| 652 | + [package] |
| 653 | + name = "foo" |
| 654 | + version = "0.1.0" |
| 655 | +
|
| 656 | + [dependencies] |
| 657 | + a = {{ git = '{}' }} |
| 658 | + "#, |
| 659 | + git_project.url() |
| 660 | + ), |
| 661 | + ) |
| 662 | + .file("src/lib.rs", "") |
| 663 | + .build(); |
| 664 | + |
| 665 | + fs::write( |
| 666 | + paths::home().join(".gitconfig"), |
| 667 | + r#" |
| 668 | + [core] |
| 669 | + autocrlf = true |
| 670 | + "#, |
| 671 | + ) |
| 672 | + .unwrap(); |
| 673 | + |
| 674 | + p.cargo("vendor --respect-source-config").run(); |
| 675 | + let output = p.read_file("vendor/a/src/lib.rs"); |
| 676 | + assert_eq!(input, output); |
| 677 | +} |
0 commit comments