diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index 4ad6e7a78b1..c25c016c056 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -3,12 +3,9 @@ use crate::util::errors::{CargoResult, CargoResultExt}; use crate::util::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo}; use crate::util::{restricted_names, Config}; use cargo_util::paths; -use git2::Config as GitConfig; -use git2::Repository as GitRepository; use serde::de; use serde::Deserialize; use std::collections::BTreeMap; -use std::env; use std::fmt; use std::io::{BufRead, BufReader, ErrorKind}; use std::path::{Path, PathBuf}; @@ -129,8 +126,14 @@ impl NewOptions { #[derive(Deserialize)] struct CargoNewConfig { + #[deprecated = "cargo-new no longer supports adding the authors field"] + #[allow(dead_code)] name: Option, + + #[deprecated = "cargo-new no longer supports adding the authors field"] + #[allow(dead_code)] email: Option, + #[serde(rename = "vcs")] version_control: Option, } @@ -666,32 +669,6 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> { init_vcs(path, vcs, config)?; write_ignore_file(path, &ignore, vcs)?; - let (discovered_name, discovered_email) = discover_author(path); - - // "Name " or "Name" or "" or None if neither name nor email is obtained - // cfg takes priority over the discovered ones - let author_name = cfg.name.or(discovered_name); - let author_email = cfg.email.or(discovered_email); - - let author = match (author_name, author_email) { - (Some(name), Some(email)) => { - if email.is_empty() { - Some(name) - } else { - Some(format!("{} <{}>", name, email)) - } - } - (Some(name), None) => Some(name), - (None, Some(email)) => { - if email.is_empty() { - None - } else { - Some(format!("<{}>", email)) - } - } - (None, None) => None, - }; - let mut cargotoml_path_specifier = String::new(); // Calculate what `[lib]` and `[[bin]]`s we need to append to `Cargo.toml`. @@ -730,7 +707,6 @@ path = {} r#"[package] name = "{}" version = "0.1.0" -authors = [{}] edition = {} {} # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -738,10 +714,6 @@ edition = {} [dependencies] {}"#, name, - match author { - Some(value) => format!("{}", toml::Value::String(value)), - None => format!(""), - }, match opts.edition { Some(edition) => toml::Value::String(edition.to_string()), None => toml::Value::String(Edition::LATEST_STABLE.to_string()), @@ -811,76 +783,3 @@ mod tests { Ok(()) } - -fn get_environment_variable(variables: &[&str]) -> Option { - variables.iter().filter_map(|var| env::var(var).ok()).next() -} - -fn discover_author(path: &Path) -> (Option, Option) { - let git_config = find_git_config(path); - let git_config = git_config.as_ref(); - - let name_variables = [ - "CARGO_NAME", - "GIT_AUTHOR_NAME", - "GIT_COMMITTER_NAME", - "USER", - "USERNAME", - "NAME", - ]; - let name = get_environment_variable(&name_variables[0..3]) - .or_else(|| git_config.and_then(|g| g.get_string("user.name").ok())) - .or_else(|| get_environment_variable(&name_variables[3..])); - - let name = name.map(|namestr| namestr.trim().to_string()); - - let email_variables = [ - "CARGO_EMAIL", - "GIT_AUTHOR_EMAIL", - "GIT_COMMITTER_EMAIL", - "EMAIL", - ]; - let email = get_environment_variable(&email_variables[0..3]) - .or_else(|| git_config.and_then(|g| g.get_string("user.email").ok())) - .or_else(|| get_environment_variable(&email_variables[3..])); - - let email = email.map(|s| { - let mut s = s.trim(); - - // In some cases emails will already have <> remove them since they - // are already added when needed. - if s.starts_with('<') && s.ends_with('>') { - s = &s[1..s.len() - 1]; - } - - s.to_string() - }); - - (name, email) -} - -fn find_git_config(path: &Path) -> Option { - match env::var("__CARGO_TEST_ROOT") { - Ok(_) => find_tests_git_config(path), - Err(_) => find_real_git_config(path), - } -} - -fn find_tests_git_config(path: &Path) -> Option { - // Don't escape the test sandbox when looking for a git repository. - // NOTE: libgit2 has support to define the path ceiling in - // git_repository_discover, but the git2 bindings do not expose that. - for path in paths::ancestors(path, None) { - if let Ok(repo) = GitRepository::open(path) { - return Some(repo.config().expect("test repo should have valid config")); - } - } - GitConfig::open_default().ok() -} - -fn find_real_git_config(path: &Path) -> Option { - GitRepository::discover(path) - .and_then(|repo| repo.config()) - .or_else(|_| GitConfig::open_default()) - .ok() -} diff --git a/src/doc/man/cargo-init.md b/src/doc/man/cargo-init.md index 74e916fab82..bdb5a82702e 100644 --- a/src/doc/man/cargo-init.md +++ b/src/doc/man/cargo-init.md @@ -20,8 +20,6 @@ will be used. If not, then a sample `src/main.rs` file will be created, or If the directory is not already in a VCS repository, then a new repository is created (see `--vcs` below). -{{> description-new-authors }} - See {{man "cargo-new" 1}} for a similar command which will create a new package in a new directory. diff --git a/src/doc/man/cargo-new.md b/src/doc/man/cargo-new.md index a8b039fc26b..d0ca9181224 100644 --- a/src/doc/man/cargo-new.md +++ b/src/doc/man/cargo-new.md @@ -15,8 +15,6 @@ includes a simple template with a `Cargo.toml` manifest, sample source file, and a VCS ignore file. If the directory is not already in a VCS repository, then a new repository is created (see `--vcs` below). -{{> description-new-authors }} - See {{man "cargo-init" 1}} for a similar command which will create a new manifest in an existing directory. diff --git a/src/doc/man/generated_txt/cargo-init.txt b/src/doc/man/generated_txt/cargo-init.txt index 559d6572b69..e96abbb28de 100644 --- a/src/doc/man/generated_txt/cargo-init.txt +++ b/src/doc/man/generated_txt/cargo-init.txt @@ -17,44 +17,6 @@ DESCRIPTION If the directory is not already in a VCS repository, then a new repository is created (see --vcs below). - The "authors" field in the manifest is determined from the environment - or configuration settings. A name is required and is determined from - (first match wins): - - o cargo-new.name Cargo config value - - o CARGO_NAME environment variable - - o GIT_AUTHOR_NAME environment variable - - o GIT_COMMITTER_NAME environment variable - - o user.name git configuration value - - o USER environment variable - - o USERNAME environment variable - - o NAME environment variable - - The email address is optional and is determined from: - - o cargo-new.email Cargo config value - - o CARGO_EMAIL environment variable - - o GIT_AUTHOR_EMAIL environment variable - - o GIT_COMMITTER_EMAIL environment variable - - o user.email git configuration value - - o EMAIL environment variable - - See the reference - for more - information about configuration files. - See cargo-new(1) for a similar command which will create a new package in a new directory. diff --git a/src/doc/man/generated_txt/cargo-new.txt b/src/doc/man/generated_txt/cargo-new.txt index 24c594d7e2a..69ccfe37521 100644 --- a/src/doc/man/generated_txt/cargo-new.txt +++ b/src/doc/man/generated_txt/cargo-new.txt @@ -12,44 +12,6 @@ DESCRIPTION source file, and a VCS ignore file. If the directory is not already in a VCS repository, then a new repository is created (see --vcs below). - The "authors" field in the manifest is determined from the environment - or configuration settings. A name is required and is determined from - (first match wins): - - o cargo-new.name Cargo config value - - o CARGO_NAME environment variable - - o GIT_AUTHOR_NAME environment variable - - o GIT_COMMITTER_NAME environment variable - - o user.name git configuration value - - o USER environment variable - - o USERNAME environment variable - - o NAME environment variable - - The email address is optional and is determined from: - - o cargo-new.email Cargo config value - - o CARGO_EMAIL environment variable - - o GIT_AUTHOR_EMAIL environment variable - - o GIT_COMMITTER_EMAIL environment variable - - o user.email git configuration value - - o EMAIL environment variable - - See the reference - for more - information about configuration files. - See cargo-init(1) for a similar command which will create a new manifest in an existing directory. diff --git a/src/doc/man/includes/description-new-authors.md b/src/doc/man/includes/description-new-authors.md deleted file mode 100644 index c3380cbf1a0..00000000000 --- a/src/doc/man/includes/description-new-authors.md +++ /dev/null @@ -1,24 +0,0 @@ -The "authors" field in the manifest is determined from the environment or -configuration settings. A name is required and is determined from (first match -wins): - -- `cargo-new.name` Cargo config value -- `CARGO_NAME` environment variable -- `GIT_AUTHOR_NAME` environment variable -- `GIT_COMMITTER_NAME` environment variable -- `user.name` git configuration value -- `USER` environment variable -- `USERNAME` environment variable -- `NAME` environment variable - -The email address is optional and is determined from: - -- `cargo-new.email` Cargo config value -- `CARGO_EMAIL` environment variable -- `GIT_AUTHOR_EMAIL` environment variable -- `GIT_COMMITTER_EMAIL` environment variable -- `user.email` git configuration value -- `EMAIL` environment variable - -See [the reference](../reference/config.html) for more information about -configuration files. diff --git a/src/doc/src/commands/cargo-init.md b/src/doc/src/commands/cargo-init.md index 3cbee888f50..4e5dc50456e 100644 --- a/src/doc/src/commands/cargo-init.md +++ b/src/doc/src/commands/cargo-init.md @@ -20,32 +20,6 @@ will be used. If not, then a sample `src/main.rs` file will be created, or If the directory is not already in a VCS repository, then a new repository is created (see `--vcs` below). -The "authors" field in the manifest is determined from the environment or -configuration settings. A name is required and is determined from (first match -wins): - -- `cargo-new.name` Cargo config value -- `CARGO_NAME` environment variable -- `GIT_AUTHOR_NAME` environment variable -- `GIT_COMMITTER_NAME` environment variable -- `user.name` git configuration value -- `USER` environment variable -- `USERNAME` environment variable -- `NAME` environment variable - -The email address is optional and is determined from: - -- `cargo-new.email` Cargo config value -- `CARGO_EMAIL` environment variable -- `GIT_AUTHOR_EMAIL` environment variable -- `GIT_COMMITTER_EMAIL` environment variable -- `user.email` git configuration value -- `EMAIL` environment variable - -See [the reference](../reference/config.html) for more information about -configuration files. - - See [cargo-new(1)](cargo-new.html) for a similar command which will create a new package in a new directory. diff --git a/src/doc/src/commands/cargo-new.md b/src/doc/src/commands/cargo-new.md index 8bf71bdb54b..8236a08fbbd 100644 --- a/src/doc/src/commands/cargo-new.md +++ b/src/doc/src/commands/cargo-new.md @@ -15,32 +15,6 @@ includes a simple template with a `Cargo.toml` manifest, sample source file, and a VCS ignore file. If the directory is not already in a VCS repository, then a new repository is created (see `--vcs` below). -The "authors" field in the manifest is determined from the environment or -configuration settings. A name is required and is determined from (first match -wins): - -- `cargo-new.name` Cargo config value -- `CARGO_NAME` environment variable -- `GIT_AUTHOR_NAME` environment variable -- `GIT_COMMITTER_NAME` environment variable -- `user.name` git configuration value -- `USER` environment variable -- `USERNAME` environment variable -- `NAME` environment variable - -The email address is optional and is determined from: - -- `cargo-new.email` Cargo config value -- `CARGO_EMAIL` environment variable -- `GIT_AUTHOR_EMAIL` environment variable -- `GIT_COMMITTER_EMAIL` environment variable -- `user.email` git configuration value -- `EMAIL` environment variable - -See [the reference](../reference/config.html) for more information about -configuration files. - - See [cargo-init(1)](cargo-init.html) for a similar command which will create a new manifest in an existing directory. diff --git a/src/doc/src/getting-started/first-steps.md b/src/doc/src/getting-started/first-steps.md index 4a4233eeb36..377e0e4da65 100644 --- a/src/doc/src/getting-started/first-steps.md +++ b/src/doc/src/getting-started/first-steps.md @@ -33,7 +33,6 @@ This is all we need to get started. First, let’s check out `Cargo.toml`: [package] name = "hello_world" version = "0.1.0" -authors = ["Your Name "] edition = "2018" [dependencies] diff --git a/src/doc/src/guide/cargo-toml-vs-cargo-lock.md b/src/doc/src/guide/cargo-toml-vs-cargo-lock.md index 39fb336d66a..f6100454eea 100644 --- a/src/doc/src/guide/cargo-toml-vs-cargo-lock.md +++ b/src/doc/src/guide/cargo-toml-vs-cargo-lock.md @@ -27,7 +27,6 @@ depend on another package: [package] name = "hello_world" version = "0.1.0" -authors = ["Your Name "] [dependencies] rand = { git = "https://github.com/rust-lang-nursery/rand.git" } @@ -63,7 +62,6 @@ manifest like this: [package] name = "hello_world" version = "0.1.0" -authors = ["Your Name "] [dependencies] rand = { git = "https://github.com/rust-lang-nursery/rand.git" } diff --git a/src/doc/src/guide/creating-a-new-project.md b/src/doc/src/guide/creating-a-new-project.md index 909978749e8..5ac22a2f267 100644 --- a/src/doc/src/guide/creating-a-new-project.md +++ b/src/doc/src/guide/creating-a-new-project.md @@ -29,7 +29,6 @@ Let’s take a closer look at `Cargo.toml`: [package] name = "hello_world" version = "0.1.0" -authors = ["Your Name "] edition = "2018" [dependencies] diff --git a/src/doc/src/guide/dependencies.md b/src/doc/src/guide/dependencies.md index 0964cbdb180..ff86900d4bc 100644 --- a/src/doc/src/guide/dependencies.md +++ b/src/doc/src/guide/dependencies.md @@ -35,7 +35,6 @@ crates: [package] name = "hello_world" version = "0.1.0" -authors = ["Your Name "] edition = "2018" [dependencies] diff --git a/src/doc/src/reference/config.md b/src/doc/src/reference/config.md index 54257da784e..8c30a1c89ef 100644 --- a/src/doc/src/reference/config.md +++ b/src/doc/src/reference/config.md @@ -68,8 +68,6 @@ dep-info-basedir = "…" # path for the base directory for targets in dep pipelining = true # rustc pipelining [cargo-new] -name = "Your Name" # name to use in `authors` field -email = "you@example.com" # email address to use in `authors` field vcs = "none" # VCS to use ('git', 'hg', 'pijul', 'fossil', 'none') [http] @@ -402,25 +400,12 @@ schedule overlapping invocations of `rustc` in parallel when possible. The `[cargo-new]` table defines defaults for the [`cargo new`] command. ##### `cargo-new.name` -* Type: string -* Default: from environment -* Environment: `CARGO_NAME` or `CARGO_CARGO_NEW_NAME` -Defines the name to use in the `authors` field when creating a new -`Cargo.toml` file. If not specified in the config, Cargo searches the -environment or your `git` configuration as described in the [`cargo new`] -documentation. +This option is deprecated and unused. ##### `cargo-new.email` -* Type: string -* Default: from environment -* Environment: `CARGO_EMAIL` or `CARGO_CARGO_NEW_EMAIL` - -Defines the email address used in the `authors` field when creating a new -`Cargo.toml` file. If not specified in the config, Cargo searches the -environment or your `git` configuration as described in the [`cargo new`] -documentation. The `email` value may be set to an empty string to prevent -Cargo from placing an address in the authors field. + +This option is deprecated and unused. ##### `cargo-new.vcs` * Type: string diff --git a/src/doc/src/reference/environment-variables.md b/src/doc/src/reference/environment-variables.md index 39ccb7e263b..9822227e4c9 100644 --- a/src/doc/src/reference/environment-variables.md +++ b/src/doc/src/reference/environment-variables.md @@ -46,8 +46,6 @@ system: will otherwise be used. See also [`build.incremental`] config value. * `CARGO_CACHE_RUSTC_INFO` — If this is set to 0 then Cargo will not try to cache compiler version information. -* `CARGO_NAME` — The author name to use for [`cargo new`]. -* `CARGO_EMAIL` — The author email to use for [`cargo new`]. * `HTTPS_PROXY` or `https_proxy` or `http_proxy` — The HTTP proxy to use, see [`http.proxy`] for more detail. * `HTTP_TIMEOUT` — The HTTP timeout in seconds, see [`http.timeout`] for more @@ -78,8 +76,6 @@ supported environment variables are: * `CARGO_BUILD_INCREMENTAL` — Incremental compilation, see [`build.incremental`]. * `CARGO_BUILD_DEP_INFO_BASEDIR` — Dep-info relative directory, see [`build.dep-info-basedir`]. * `CARGO_BUILD_PIPELINING` — Whether or not to use `rustc` pipelining, see [`build.pipelining`]. -* `CARGO_CARGO_NEW_NAME` — The author name to use with [`cargo new`], see [`cargo-new.name`]. -* `CARGO_CARGO_NEW_EMAIL` — The author email to use with [`cargo new`], see [`cargo-new.email`]. * `CARGO_CARGO_NEW_VCS` — The default source control system with [`cargo new`], see [`cargo-new.vcs`]. * `CARGO_HTTP_DEBUG` — Enables HTTP debugging, see [`http.debug`]. * `CARGO_HTTP_PROXY` — Enables HTTP proxy, see [`http.proxy`]. diff --git a/src/doc/src/reference/manifest.md b/src/doc/src/reference/manifest.md index 76eeaf46b91..de9313d73dd 100644 --- a/src/doc/src/reference/manifest.md +++ b/src/doc/src/reference/manifest.md @@ -107,14 +107,19 @@ breaking change. #### The `authors` field -The `authors` field lists people or organizations that are considered the -"authors" of the package. The exact meaning is open to interpretation — it may -list the original or primary authors, current maintainers, or owners of the -package. These names will be listed on the crate's page on -[crates.io]. An optional email address may be included within angled -brackets at the end of each author. - -> **Note**: [crates.io] requires at least one author to be listed. +The optional `authors` field lists people or organizations that are considered +the "authors" of the package. The exact meaning is open to interpretation — it +may list the original or primary authors, current maintainers, or owners of the +package. An optional email address may be included within angled brackets at +the end of each author entry. + +This field is only surfaced in package metadata and in the `CARGO_PKG_AUTHORS` +environment variable within `build.rs`. It is not displayed in the [crates.io] +user interface. + +> **Warning**: Package manifests cannot be changed once published, so this +> field cannot be changed or removed in already-published versions of a +> package. #### The `edition` field diff --git a/src/doc/src/reference/overriding-dependencies.md b/src/doc/src/reference/overriding-dependencies.md index 6cad545b79b..5700f525147 100644 --- a/src/doc/src/reference/overriding-dependencies.md +++ b/src/doc/src/reference/overriding-dependencies.md @@ -49,7 +49,6 @@ try to fix the bug! Originally your manifest will look like: [package] name = "my-library" version = "0.1.0" -authors = ["..."] [dependencies] uuid = "1.0" @@ -131,7 +130,6 @@ repository we'll edit our `Cargo.toml` to look like [package] name = "my-library" version = "0.1.0" -authors = ["..."] [dependencies] uuid = "1.0.1" @@ -157,7 +155,6 @@ It's also worth noting that `[patch]` applies *transitively*. Let's say you use [package] name = "my-binary" version = "0.1.0" -authors = ["..."] [dependencies] my-library = { git = 'https://example.com/git/my-library' } @@ -212,7 +209,6 @@ look at the `my-binary` manifest from above again as well: [package] name = "my-binary" version = "0.1.0" -authors = ["..."] [dependencies] my-library = { git = 'https://example.com/git/my-library' } diff --git a/src/doc/src/reference/publishing.md b/src/doc/src/reference/publishing.md index df23caf50e9..05f706b84b7 100644 --- a/src/doc/src/reference/publishing.md +++ b/src/doc/src/reference/publishing.md @@ -34,7 +34,6 @@ Check out the [metadata you can specify](manifest.md) in `Cargo.toml` to ensure your crate can be discovered more easily! Before publishing, make sure you have filled out the following fields: -- [`authors`] - [`license` or `license-file`] - [`description`] - [`homepage`] @@ -258,7 +257,6 @@ request the org owner to do so. [RFC 1105]: https://github.com/rust-lang/rfcs/blob/master/text/1105-api-evolution.md [Rust API Guidelines]: https://rust-lang.github.io/api-guidelines/ -[`authors`]: manifest.md#the-authors-field [`cargo login`]: ../commands/cargo-login.md [`cargo package`]: ../commands/cargo-package.md [`cargo publish`]: ../commands/cargo-publish.md diff --git a/src/doc/src/reference/registries.md b/src/doc/src/reference/registries.md index 675645ce11d..05289706f75 100644 --- a/src/doc/src/reference/registries.md +++ b/src/doc/src/reference/registries.md @@ -385,7 +385,7 @@ considered as an exhaustive list of restrictions [crates.io] imposes. "extras": ["rand/simd_support"] }, // List of strings of the authors. - // May be empty. crates.io requires at least one entry. + // May be empty. "authors": ["Alice "], // Description field from the manifest. // May be null. crates.io requires at least some content. diff --git a/src/etc/man/cargo-init.1 b/src/etc/man/cargo-init.1 index 168282ad4e8..4cba15fb424 100644 --- a/src/etc/man/cargo-init.1 +++ b/src/etc/man/cargo-init.1 @@ -18,71 +18,6 @@ will be used. If not, then a sample \fBsrc/main.rs\fR file will be created, or If the directory is not already in a VCS repository, then a new repository is created (see \fB\-\-vcs\fR below). .sp -The "authors" field in the manifest is determined from the environment or -configuration settings. A name is required and is determined from (first match -wins): -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBcargo\-new.name\fR Cargo config value -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBCARGO_NAME\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBGIT_AUTHOR_NAME\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBGIT_COMMITTER_NAME\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBuser.name\fR git configuration value -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBUSER\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBUSERNAME\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBNAME\fR environment variable -.RE -.sp -The email address is optional and is determined from: -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBcargo\-new.email\fR Cargo config value -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBCARGO_EMAIL\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBGIT_AUTHOR_EMAIL\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBGIT_COMMITTER_EMAIL\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBuser.email\fR git configuration value -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBEMAIL\fR environment variable -.RE -.sp -See \fIthe reference\fR for more information about -configuration files. -.sp See \fBcargo\-new\fR(1) for a similar command which will create a new package in a new directory. .SH "OPTIONS" diff --git a/src/etc/man/cargo-new.1 b/src/etc/man/cargo-new.1 index d24a9149f52..6d507b704f5 100644 --- a/src/etc/man/cargo-new.1 +++ b/src/etc/man/cargo-new.1 @@ -13,71 +13,6 @@ includes a simple template with a \fBCargo.toml\fR manifest, sample source file, and a VCS ignore file. If the directory is not already in a VCS repository, then a new repository is created (see \fB\-\-vcs\fR below). .sp -The "authors" field in the manifest is determined from the environment or -configuration settings. A name is required and is determined from (first match -wins): -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBcargo\-new.name\fR Cargo config value -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBCARGO_NAME\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBGIT_AUTHOR_NAME\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBGIT_COMMITTER_NAME\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBuser.name\fR git configuration value -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBUSER\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBUSERNAME\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBNAME\fR environment variable -.RE -.sp -The email address is optional and is determined from: -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBcargo\-new.email\fR Cargo config value -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBCARGO_EMAIL\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBGIT_AUTHOR_EMAIL\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBGIT_COMMITTER_EMAIL\fR environment variable -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBuser.email\fR git configuration value -.RE -.sp -.RS 4 -\h'-04'\(bu\h'+02'\fBEMAIL\fR environment variable -.RE -.sp -See \fIthe reference\fR for more information about -configuration files. -.sp See \fBcargo\-init\fR(1) for a similar command which will create a new manifest in an existing directory. .SH "OPTIONS" diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index 2b598485a3b..022b5b9ac2f 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -94,7 +94,7 @@ fn bad4() { ".cargo/config", r#" [cargo-new] - name = false + vcs = false "#, ) .build(); @@ -105,7 +105,7 @@ fn bad4() { [ERROR] Failed to create package `foo` at `[..]` Caused by: - error in [..]config: `cargo-new.name` expected a string, but found a boolean + error in [..]config: `cargo-new.vcs` expected a string, but found a boolean ", ) .run(); diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs index 04e3051c785..5e26a795c64 100644 --- a/tests/testsuite/cargo_command.rs +++ b/tests/testsuite/cargo_command.rs @@ -254,21 +254,18 @@ fn override_cargo_home() { &my_home.join("config"), r#" [cargo-new] - name = "foo" - email = "bar" - git = false + vcs = "none" "#, ) .unwrap(); - cargo_process("new foo") - .env("USER", "foo") - .env("CARGO_HOME", &my_home) - .run(); + cargo_process("new foo").env("CARGO_HOME", &my_home).run(); + + assert!(!paths::root().join("foo/.git").is_dir()); + + cargo_process("new foo2").run(); - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["foo "]"#)); + assert!(paths::root().join("foo2/.git").is_dir()); } #[cargo_test] diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index 5396f3f4ccf..4379f0530aa 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -26,7 +26,6 @@ fn mercurial_available() -> bool { #[cargo_test] fn simple_lib() { cargo_process("init --lib --vcs none --edition 2015") - .env("USER", "foo") .with_stderr("[CREATED] library package") .run(); @@ -42,7 +41,6 @@ fn simple_bin() { let path = paths::root().join("foo"); fs::create_dir(&path).unwrap(); cargo_process("init --bin --vcs none --edition 2015") - .env("USER", "foo") .cwd(&path) .with_stderr("[CREATED] binary (application) package") .run(); @@ -66,9 +64,7 @@ fn simple_git_ignore_exists() { ) .unwrap(); - cargo_process("init --lib foo --edition 2015") - .env("USER", "foo") - .run(); + cargo_process("init --lib foo --edition 2015").run(); assert!(paths::root().is_dir()); assert!(paths::root().join("foo/Cargo.toml").is_file()); @@ -99,9 +95,7 @@ fn git_ignore_exists_no_conflicting_entries() { fs::create_dir_all(paths::root().join("foo")).unwrap(); fs::write(paths::root().join("foo/.gitignore"), "**/some.file").unwrap(); - cargo_process("init --lib foo --edition 2015") - .env("USER", "foo") - .run(); + cargo_process("init --lib foo --edition 2015").run(); let fp = paths::root().join("foo/.gitignore"); let contents = fs::read_to_string(&fp).unwrap(); @@ -118,7 +112,6 @@ fn git_ignore_exists_no_conflicting_entries() { #[cargo_test] fn both_lib_and_bin() { cargo_process("init --lib --bin") - .env("USER", "foo") .with_status(101) .with_stderr("[ERROR] can't specify both lib and binary outputs") .run(); @@ -139,15 +132,9 @@ fn bin_already_exists(explicit: bool, rellocation: &str) { fs::write(&sourcefile_path, content).unwrap(); if explicit { - cargo_process("init --bin --vcs none") - .env("USER", "foo") - .cwd(&path) - .run(); + cargo_process("init --bin --vcs none").cwd(&path).run(); } else { - cargo_process("init --vcs none") - .env("USER", "foo") - .cwd(&path) - .run(); + cargo_process("init --vcs none").cwd(&path).run(); } assert!(paths::root().join("foo/Cargo.toml").is_file()); @@ -200,7 +187,6 @@ fn confused_by_multiple_lib_files() { fs::write(path2, r#" fn qqq () { println!("Hello, world 3!"); }"#).unwrap(); cargo_process("init --vcs none") - .env("USER", "foo") .cwd(&path) .with_status(101) .with_stderr( @@ -224,7 +210,6 @@ fn multibin_project_name_clash() { fs::write(path2, r#"fn main () { println!("Hello, world 3!"); }"#).unwrap(); cargo_process("init --lib --vcs none") - .env("USER", "foo") .cwd(&path) .with_status(101) .with_stderr( @@ -249,10 +234,7 @@ fn lib_already_exists(rellocation: &str) { let content = "pub fn qqq() {}"; fs::write(&sourcefile_path, content).unwrap(); - cargo_process("init --vcs none") - .env("USER", "foo") - .cwd(&path) - .run(); + cargo_process("init --vcs none").cwd(&path).run(); assert!(paths::root().join("foo/Cargo.toml").is_file()); assert!(!paths::root().join("foo/src/main.rs").is_file()); @@ -274,9 +256,7 @@ fn lib_already_exists_nosrc() { #[cargo_test] fn simple_git() { - cargo_process("init --lib --vcs git") - .env("USER", "foo") - .run(); + cargo_process("init --lib --vcs git").run(); assert!(paths::root().join("Cargo.toml").is_file()); assert!(paths::root().join("src/lib.rs").is_file()); @@ -286,7 +266,7 @@ fn simple_git() { #[cargo_test] fn auto_git() { - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); assert!(paths::root().join("Cargo.toml").is_file()); assert!(paths::root().join("src/lib.rs").is_file()); @@ -300,7 +280,6 @@ fn invalid_dir_name() { fs::create_dir_all(&foo).unwrap(); cargo_process("init") .cwd(foo.clone()) - .env("USER", "foo") .with_status(101) .with_stderr( "\ @@ -328,7 +307,6 @@ fn reserved_name() { fs::create_dir_all(&test).unwrap(); cargo_process("init") .cwd(test.clone()) - .env("USER", "foo") .with_status(101) .with_stderr( "\ @@ -354,7 +332,7 @@ or change the name in Cargo.toml with: fn git_autodetect() { fs::create_dir(&paths::root().join(".git")).unwrap(); - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); assert!(paths::root().join("Cargo.toml").is_file()); assert!(paths::root().join("src/lib.rs").is_file()); @@ -366,7 +344,7 @@ fn git_autodetect() { fn mercurial_autodetect() { fs::create_dir(&paths::root().join(".hg")).unwrap(); - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); assert!(paths::root().join("Cargo.toml").is_file()); assert!(paths::root().join("src/lib.rs").is_file()); @@ -380,7 +358,7 @@ fn gitignore_appended_not_replaced() { fs::write(&paths::root().join(".gitignore"), "qqqqqq\n").unwrap(); - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); assert!(paths::root().join("Cargo.toml").is_file()); assert!(paths::root().join("src/lib.rs").is_file()); @@ -397,7 +375,7 @@ fn gitignore_added_newline_in_existing() { fs::write(&paths::root().join(".gitignore"), "first").unwrap(); - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); assert!(paths::root().join(".gitignore").is_file()); @@ -409,7 +387,7 @@ fn gitignore_added_newline_in_existing() { fn gitignore_no_newline_in_new() { fs::create_dir(&paths::root().join(".git")).unwrap(); - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); assert!(paths::root().join(".gitignore").is_file()); @@ -423,7 +401,7 @@ fn mercurial_added_newline_in_existing() { fs::write(&paths::root().join(".hgignore"), "first").unwrap(); - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); assert!(paths::root().join(".hgignore").is_file()); @@ -435,7 +413,7 @@ fn mercurial_added_newline_in_existing() { fn mercurial_no_newline_in_new() { fs::create_dir(&paths::root().join(".hg")).unwrap(); - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); assert!(paths::root().join(".hgignore").is_file()); @@ -445,9 +423,7 @@ fn mercurial_no_newline_in_new() { #[cargo_test] fn terminating_newline_in_new_git_ignore() { - cargo_process("init --vcs git --lib") - .env("USER", "foo") - .run(); + cargo_process("init --vcs git --lib").run(); let content = fs::read_to_string(&paths::root().join(".gitignore")).unwrap(); @@ -461,9 +437,7 @@ fn terminating_newline_in_new_mercurial_ignore() { if !mercurial_available() { return; } - cargo_process("init --vcs hg --lib") - .env("USER", "foo") - .run(); + cargo_process("init --vcs hg --lib").run(); let content = fs::read_to_string(&paths::root().join(".hgignore")).unwrap(); @@ -477,7 +451,7 @@ fn terminating_newline_in_existing_git_ignore() { fs::create_dir(&paths::root().join(".git")).unwrap(); fs::write(&paths::root().join(".gitignore"), b"first").unwrap(); - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); let content = fs::read_to_string(&paths::root().join(".gitignore")).unwrap(); @@ -491,7 +465,7 @@ fn terminating_newline_in_existing_mercurial_ignore() { fs::create_dir(&paths::root().join(".hg")).unwrap(); fs::write(&paths::root().join(".hgignore"), b"first").unwrap(); - cargo_process("init --lib").env("USER", "foo").run(); + cargo_process("init --lib").run(); let content = fs::read_to_string(&paths::root().join(".hgignore")).unwrap(); @@ -504,9 +478,7 @@ fn terminating_newline_in_existing_mercurial_ignore() { fn cargo_lock_gitignored_if_lib1() { fs::create_dir(&paths::root().join(".git")).unwrap(); - cargo_process("init --lib --vcs git") - .env("USER", "foo") - .run(); + cargo_process("init --lib --vcs git").run(); assert!(paths::root().join(".gitignore").is_file()); @@ -520,7 +492,7 @@ fn cargo_lock_gitignored_if_lib2() { fs::write(&paths::root().join("lib.rs"), "").unwrap(); - cargo_process("init --vcs git").env("USER", "foo").run(); + cargo_process("init --vcs git").run(); assert!(paths::root().join(".gitignore").is_file()); @@ -532,9 +504,7 @@ fn cargo_lock_gitignored_if_lib2() { fn cargo_lock_not_gitignored_if_bin1() { fs::create_dir(&paths::root().join(".git")).unwrap(); - cargo_process("init --vcs git --bin") - .env("USER", "foo") - .run(); + cargo_process("init --vcs git --bin").run(); assert!(paths::root().join(".gitignore").is_file()); @@ -548,7 +518,7 @@ fn cargo_lock_not_gitignored_if_bin2() { fs::write(&paths::root().join("main.rs"), "").unwrap(); - cargo_process("init --vcs git").env("USER", "foo").run(); + cargo_process("init --vcs git").run(); assert!(paths::root().join(".gitignore").is_file()); @@ -558,9 +528,7 @@ fn cargo_lock_not_gitignored_if_bin2() { #[cargo_test] fn with_argument() { - cargo_process("init foo --vcs none") - .env("USER", "foo") - .run(); + cargo_process("init foo --vcs none").run(); assert!(paths::root().join("foo/Cargo.toml").is_file()); } @@ -595,7 +563,6 @@ fn formats_source() { fs::write(&paths::root().join("rustfmt.toml"), "tab_spaces = 2").unwrap(); cargo_process("init --lib") - .env("USER", "foo") .with_stderr("[CREATED] library package") .run(); @@ -615,7 +582,6 @@ mod tests { #[cargo_test] fn ignores_failure_to_format_source() { cargo_process("init --lib") - .env("USER", "foo") .env("PATH", "") // pretend that `rustfmt` is missing .with_stderr("[CREATED] library package") .run(); diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index 9a7f71cf125..fd5499eaea9 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -1,7 +1,7 @@ //! Tests for the `cargo new` command. -use cargo_test_support::paths::{self, CargoPathExt}; -use cargo_test_support::{cargo_process, git_process}; +use cargo_test_support::cargo_process; +use cargo_test_support::paths; use std::env; use std::fs::{self, File}; @@ -15,7 +15,6 @@ fn create_empty_gitconfig() { #[cargo_test] fn simple_lib() { cargo_process("new --lib foo --vcs none --edition 2015") - .env("USER", "foo") .with_stderr("[CREATED] library `foo` package") .run(); @@ -44,7 +43,6 @@ mod tests { #[cargo_test] fn simple_bin() { cargo_process("new --bin foo --edition 2015") - .env("USER", "foo") .with_stderr("[CREATED] binary (application) `foo` package") .run(); @@ -61,7 +59,6 @@ fn simple_bin() { #[cargo_test] fn both_lib_and_bin() { cargo_process("new --lib --bin foo") - .env("USER", "foo") .with_status(101) .with_stderr("[ERROR] can't specify both lib and binary outputs") .run(); @@ -69,9 +66,7 @@ fn both_lib_and_bin() { #[cargo_test] fn simple_git() { - cargo_process("new --lib foo --edition 2015") - .env("USER", "foo") - .run(); + cargo_process("new --lib foo --edition 2015").run(); assert!(paths::root().is_dir()); assert!(paths::root().join("foo/Cargo.toml").is_file()); @@ -169,7 +164,6 @@ If you need a package name to not match the directory name, consider using --nam .run(); cargo_process("new --lib incremental") - .env("USER", "foo") .with_stderr( "\ [WARNING] the name `incremental` will not support binary executables with that name, \ @@ -205,7 +199,6 @@ or change the name in Cargo.toml with: #[cargo_test] fn std_name() { cargo_process("new core") - .env("USER", "foo") .with_stderr( "\ [WARNING] the name `core` is part of Rust's standard library @@ -226,256 +219,6 @@ or change the name in Cargo.toml with: .run(); } -#[cargo_test] -fn finds_author_user() { - create_empty_gitconfig(); - cargo_process("new foo").env("USER", "foo").run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["foo"]"#)); -} - -#[cargo_test] -fn author_without_user_or_email() { - create_empty_gitconfig(); - cargo_process("new foo") - .env_remove("USER") - .env_remove("USERNAME") - .env_remove("NAME") - .env_remove("EMAIL") - .run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = []"#)); -} - -#[cargo_test] -fn finds_author_email_only() { - create_empty_gitconfig(); - cargo_process("new foo") - .env_remove("USER") - .env_remove("USERNAME") - .env_remove("NAME") - .env_remove("EMAIL") - .env("EMAIL", "baz") - .run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = [""]"#)); -} - -#[cargo_test] -fn finds_author_user_escaped() { - create_empty_gitconfig(); - cargo_process("new foo").env("USER", "foo \"bar\"").run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["foo \"bar\""]"#)); -} - -#[cargo_test] -fn finds_author_username() { - create_empty_gitconfig(); - cargo_process("new foo") - .env_remove("USER") - .env("USERNAME", "foo") - .run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["foo"]"#)); -} - -#[cargo_test] -fn finds_author_name() { - create_empty_gitconfig(); - cargo_process("new foo") - .env_remove("USERNAME") - .env("NAME", "foo") - .run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["foo"]"#)); -} - -#[cargo_test] -fn finds_author_priority() { - cargo_process("new foo") - .env("USER", "bar2") - .env("EMAIL", "baz2") - .env("CARGO_NAME", "bar") - .env("CARGO_EMAIL", "baz") - .run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["bar "]"#)); -} - -#[cargo_test] -fn finds_author_email() { - create_empty_gitconfig(); - cargo_process("new foo") - .env("USER", "bar") - .env("EMAIL", "baz") - .run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["bar "]"#)); -} - -#[cargo_test] -fn finds_author_git() { - git_process("config --global user.name bar").exec().unwrap(); - git_process("config --global user.email baz") - .exec() - .unwrap(); - cargo_process("new foo").env("USER", "foo").run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["bar "]"#)); -} - -#[cargo_test] -fn finds_local_author_git() { - git_process("init").exec_with_output().unwrap(); - git_process("config --global user.name foo").exec().unwrap(); - git_process("config --global user.email foo@bar") - .exec() - .unwrap(); - - // Set local git user config - git_process("config user.name bar").exec().unwrap(); - git_process("config user.email baz").exec().unwrap(); - cargo_process("init").env("USER", "foo").run(); - - let toml = paths::root().join("Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["bar "]"#)); -} - -#[cargo_test] -fn finds_git_author() { - cargo_process("new foo") - .env("GIT_AUTHOR_NAME", "foo") - .env("GIT_AUTHOR_EMAIL", "gitfoo") - .run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!( - contents.contains(r#"authors = ["foo "]"#), - "{}", - contents - ); -} - -#[cargo_test] -fn finds_git_author_in_included_config() { - let included_gitconfig = paths::root().join("foo").join(".gitconfig"); - included_gitconfig.parent().unwrap().mkdir_p(); - fs::write( - &included_gitconfig, - r#" - [user] - name = foo - email = bar - "#, - ) - .unwrap(); - - let gitconfig = paths::home().join(".gitconfig"); - fs::write( - &gitconfig, - format!( - r#" - [includeIf "gitdir/i:{}"] - path = {} - "#, - included_gitconfig - .parent() - .unwrap() - .join("") - .display() - .to_string() - .replace("\\", "/"), - included_gitconfig.display().to_string().replace("\\", "/"), - ) - .as_bytes(), - ) - .unwrap(); - - cargo_process("new foo/bar").run(); - let toml = paths::root().join("foo/bar/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!( - contents.contains(r#"authors = ["foo "]"#), - "{}", - contents - ); -} - -#[cargo_test] -fn finds_git_committer() { - create_empty_gitconfig(); - cargo_process("new foo") - .env_remove("USER") - .env("GIT_COMMITTER_NAME", "foo") - .env("GIT_COMMITTER_EMAIL", "gitfoo") - .run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["foo "]"#)); -} - -#[cargo_test] -fn author_prefers_cargo() { - git_process("config --global user.name foo").exec().unwrap(); - git_process("config --global user.email bar") - .exec() - .unwrap(); - let root = paths::root(); - fs::create_dir(&root.join(".cargo")).unwrap(); - fs::write( - &root.join(".cargo/config"), - r#" - [cargo-new] - name = "new-foo" - email = "new-bar" - vcs = "none" - "#, - ) - .unwrap(); - - cargo_process("new foo").env("USER", "foo").run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["new-foo "]"#)); - assert!(!root.join("foo/.gitignore").exists()); -} - -#[cargo_test] -fn strip_angle_bracket_author_email() { - create_empty_gitconfig(); - cargo_process("new foo") - .env("USER", "bar") - .env("EMAIL", "") - .run(); - - let toml = paths::root().join("foo/Cargo.toml"); - let contents = fs::read_to_string(&toml).unwrap(); - assert!(contents.contains(r#"authors = ["bar "]"#)); -} - #[cargo_test] fn git_prefers_command_line() { let root = paths::root(); @@ -491,22 +234,23 @@ fn git_prefers_command_line() { ) .unwrap(); - cargo_process("new foo --vcs git").env("USER", "foo").run(); + cargo_process("new foo --vcs git").run(); assert!(paths::root().join("foo/.gitignore").exists()); + assert!(!fs::read_to_string(paths::root().join("foo/Cargo.toml")) + .unwrap() + .contains("authors =")); } #[cargo_test] fn subpackage_no_git() { - cargo_process("new foo").env("USER", "foo").run(); + cargo_process("new foo").run(); assert!(paths::root().join("foo/.git").is_dir()); assert!(paths::root().join("foo/.gitignore").is_file()); let subpackage = paths::root().join("foo").join("components"); fs::create_dir(&subpackage).unwrap(); - cargo_process("new foo/components/subcomponent") - .env("USER", "foo") - .run(); + cargo_process("new foo/components/subcomponent").run(); assert!(!paths::root() .join("foo/components/subcomponent/.git") @@ -518,7 +262,7 @@ fn subpackage_no_git() { #[cargo_test] fn subpackage_git_with_gitignore() { - cargo_process("new foo").env("USER", "foo").run(); + cargo_process("new foo").run(); assert!(paths::root().join("foo/.git").is_dir()); assert!(paths::root().join("foo/.gitignore").is_file()); @@ -528,9 +272,7 @@ fn subpackage_git_with_gitignore() { let subpackage = paths::root().join("foo/components"); fs::create_dir(&subpackage).unwrap(); - cargo_process("new foo/components/subcomponent") - .env("USER", "foo") - .run(); + cargo_process("new foo/components/subcomponent").run(); assert!(paths::root() .join("foo/components/subcomponent/.git") @@ -542,13 +284,11 @@ fn subpackage_git_with_gitignore() { #[cargo_test] fn subpackage_git_with_vcs_arg() { - cargo_process("new foo").env("USER", "foo").run(); + cargo_process("new foo").run(); let subpackage = paths::root().join("foo").join("components"); fs::create_dir(&subpackage).unwrap(); - cargo_process("new foo/components/subcomponent --vcs git") - .env("USER", "foo") - .run(); + cargo_process("new foo/components/subcomponent --vcs git").run(); assert!(paths::root() .join("foo/components/subcomponent/.git") @@ -593,32 +333,27 @@ or change the name in Cargo.toml with: #[cargo_test] fn explicit_project_name() { cargo_process("new --lib foo --name bar") - .env("USER", "foo") .with_stderr("[CREATED] library `bar` package") .run(); } #[cargo_test] fn new_with_edition_2015() { - cargo_process("new --edition 2015 foo") - .env("USER", "foo") - .run(); + cargo_process("new --edition 2015 foo").run(); let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap(); assert!(manifest.contains("edition = \"2015\"")); } #[cargo_test] fn new_with_edition_2018() { - cargo_process("new --edition 2018 foo") - .env("USER", "foo") - .run(); + cargo_process("new --edition 2018 foo").run(); let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap(); assert!(manifest.contains("edition = \"2018\"")); } #[cargo_test] fn new_default_edition() { - cargo_process("new foo").env("USER", "foo").run(); + cargo_process("new foo").run(); let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap(); assert!(manifest.contains("edition = \"2018\"")); } @@ -626,26 +361,14 @@ fn new_default_edition() { #[cargo_test] fn new_with_bad_edition() { cargo_process("new --edition something_else foo") - .env("USER", "foo") .with_stderr_contains("error: 'something_else' isn't a valid value[..]") .with_status(1) .run(); } -#[cargo_test] -fn new_with_blank_email() { - cargo_process("new foo") - .env("CARGO_NAME", "Sen") - .env("CARGO_EMAIL", "") - .run(); - - let contents = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap(); - assert!(contents.contains(r#"authors = ["Sen"]"#), "{}", contents); -} - #[cargo_test] fn new_with_reference_link() { - cargo_process("new foo").env("USER", "foo").run(); + cargo_process("new foo").run(); let contents = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap(); assert!(contents.contains("# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html")) @@ -653,7 +376,7 @@ fn new_with_reference_link() { #[cargo_test] fn lockfile_constant_during_new() { - cargo_process("new foo").env("USER", "foo").run(); + cargo_process("new foo").run(); cargo_process("build").cwd(&paths::root().join("foo")).run(); let before = fs::read_to_string(paths::root().join("foo/Cargo.lock")).unwrap(); @@ -666,7 +389,6 @@ fn lockfile_constant_during_new() { fn restricted_windows_name() { if cfg!(windows) { cargo_process("new nul") - .env("USER", "foo") .with_status(101) .with_stderr( "\ @@ -677,7 +399,6 @@ If you need a package name to not match the directory name, consider using --nam .run(); } else { cargo_process("new nul") - .env("USER", "foo") .with_stderr( "\ [WARNING] the name `nul` is a reserved Windows filename @@ -692,7 +413,6 @@ This package will not work on Windows platforms. #[cargo_test] fn non_ascii_name() { cargo_process("new Привет") - .env("USER", "foo") .with_stderr( "\ [WARNING] the name `Привет` contains non-ASCII characters @@ -707,7 +427,6 @@ Support for non-ASCII crate names is experimental and only valid on the nightly fn non_ascii_name_invalid() { // These are alphanumeric characters, but not Unicode XID. cargo_process("new ⒶⒷⒸ") - .env("USER", "foo") .with_status(101) .with_stderr( "\ @@ -728,7 +447,6 @@ or change the name in Cargo.toml with: .run(); cargo_process("new a¼") - .env("USER", "foo") .with_status(101) .with_stderr( "\ @@ -753,7 +471,7 @@ or change the name in Cargo.toml with: fn git_default_branch() { // Check for init.defaultBranch support. create_empty_gitconfig(); - cargo_process("new foo").env("USER", "foo").run(); + cargo_process("new foo").run(); let repo = git2::Repository::open(paths::root().join("foo")).unwrap(); let head = repo.find_reference("HEAD").unwrap(); assert_eq!(head.symbolic_target().unwrap(), "refs/heads/master"); @@ -766,7 +484,7 @@ fn git_default_branch() { "#, ) .unwrap(); - cargo_process("new bar").env("USER", "foo").run(); + cargo_process("new bar").run(); let repo = git2::Repository::open(paths::root().join("bar")).unwrap(); let head = repo.find_reference("HEAD").unwrap(); assert_eq!(head.symbolic_target().unwrap(), "refs/heads/hello"); diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 2ab753ee6c2..ace60d77f83 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -1031,7 +1031,6 @@ fn new_warns_you_this_will_not_work() { let p = p.build(); p.cargo("new --lib bar") - .env("USER", "foo") .with_stderr( "\ warning: compiling this new package may not work due to invalid workspace configuration @@ -1053,7 +1052,6 @@ root: [..] fn new_warning_with_corrupt_ws() { let p = project().file("Cargo.toml", "asdf").build(); p.cargo("new bar") - .env("USER", "foo") .with_stderr( "\ [WARNING] compiling this new package may not work due to invalid workspace configuration