mirror of
https://github.com/rust-lang/cargo
synced 2024-10-02 05:53:53 +00:00
Include untracked files
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
parent
25f7d4b09a
commit
3189dc3b06
|
@ -154,14 +154,7 @@ fn check_version_control(config: &Config, opts: &FixOptions) -> CargoResult<()>
|
|||
if let Ok(repo) = git2::Repository::discover(config.cwd()) {
|
||||
let mut repo_opts = git2::StatusOptions::new();
|
||||
repo_opts.include_ignored(false);
|
||||
if repo.is_empty()? && !opts.allow_dirty {
|
||||
bail!(
|
||||
"no commits found in the git repository, and \
|
||||
`cargo fix` can potentially perform destructive changes; if you'd \
|
||||
like to suppress this error pass `--allow-dirty`, \
|
||||
or commit your changes"
|
||||
)
|
||||
}
|
||||
repo_opts.include_untracked(true);
|
||||
for status in repo.statuses(Some(&mut repo_opts))?.iter() {
|
||||
if let Some(path) = status.path() {
|
||||
match status.status() {
|
||||
|
|
|
@ -772,7 +772,7 @@ commit the changes to these files:
|
|||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn errors_on_empty_repo() {
|
||||
fn errors_about_untracked_files() {
|
||||
let mut git_project = project().at("foo");
|
||||
git_project = git_project.file("src/lib.rs", "pub fn foo() {}");
|
||||
let p = git_project.build();
|
||||
|
@ -782,10 +782,15 @@ fn errors_on_empty_repo() {
|
|||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
error: no commits found in the git repository, \
|
||||
and `cargo fix` can potentially perform destructive changes; \
|
||||
if you'd like to suppress this error pass `--allow-dirty`, \
|
||||
or commit your changes
|
||||
error: the working directory of this package has uncommitted changes, \
|
||||
and `cargo fix` can potentially perform destructive changes; if you'd \
|
||||
like to suppress this error pass `--allow-dirty`, `--allow-staged`, or \
|
||||
commit the changes to these files:
|
||||
|
||||
* Cargo.toml (dirty)
|
||||
* src/ (dirty)
|
||||
|
||||
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
|
Loading…
Reference in a new issue