Commit Graph

166 Commits

Author SHA1 Message Date
Jonathan Claudius 0c3851c017
HTTPS all the things 2019-01-30 15:34:37 -05:00
bors c9fa7db4d4 Auto merge of #6453 - spacekookie:publish-featured, r=alexcrichton
Adding feature-flags to `cargo publish` and `cargo package`

This change adds the `--features` and `--all-features` flags to the
above mentioned commands. This is to allow publishing of crates that
have certain feature requirements for compilation, without having to
rely on `--no-verify` which isn't good practise.

This PR adds two new fields `features` and `all_features` to both the
`PackageOpts` and `PublishOpts` and also adds the argument options
to the CLI commands.

Merging this feature will allow people to publish crates on crates.io
that require some feature flag to compile (or all?) without needing
to rely on not checking the package before uploading, potentially
resulting in less packaging errors and broken packages.
2019-01-10 18:37:22 +00:00
Katharina Fey b29e37968a
Adding support for `no-default-features` to package and publish 2019-01-09 18:30:54 +01:00
Eric Huss 0a4cfa630f publish: rework the crates.io detection logic.
The old code used an unreliable method to detect if `cargo publish` was publishing to crates.io. This should work even if the `--index` flag is used.

Also includes a very minor rewording of an error message mentioning crates.io, even for alternative registries.
2019-01-05 10:56:49 -08:00
Eric Huss 3d84d0ad77 Add dependency `registry` to `cargo metadata`.
This adds the `registry` field for dependencies for alternate registries in
`cargo metadata`.
2018-12-29 21:14:25 -08:00
Katharina Fey 40cca8058d
Undoing bad formatting changes and removing redundant struct fields 2018-12-29 18:18:50 +01:00
Katharina Fey 256fc39492
Adding feature-flags to `cargo publish` and `cargo package`
This change adds the `--features` and `--all-features` flags to the
above mentioned commands. This is to allow publishing of crates that
have certain feature requirements for compilation, without having to
rely on `--no-verify` which isn't good practise.

This PR adds two new fields `features` and `all_features` to both the
`PackageOpts` and `PublishOpts` and also adds the argument options
to the CLI commands.

Merging this feature will allow people to publish crates on crates.io
that require some feature flag to compile (or all?) without needing
to rely on not checking the package before uploading, potentially
resulting in less packaging errors and broken packages.
2018-12-26 12:47:02 +01:00
Eric Huss 70f84bf3b0 Rewrite `login` and registry cleanups. 2018-12-20 04:34:35 -08:00
Eric Huss 080f0b34c4 Restrict registry names to same style as package names. 2018-12-19 20:36:13 -08:00
Dale Wijnand 54c4214251
Remove trailing extern crate usage 2018-12-13 15:21:32 +00:00
Alex Crichton b8b7faee50 Run `cargo fix --edition-idioms` and fixup output
This gets Cargo passing the `--edition-idioms` lints and more down the
road of the 2018 edition!
2018-12-11 05:45:46 -08:00
Alex Crichton 9ed82b5779 Start using 2018 idioms in Cargo
Remove a number of `extern crate` directives and tweak a number of
imports. Not all `extern crate` is gone yet but this is the bulk of
them!
2018-12-11 05:45:46 -08:00
Alex Crichton fecb724643 Format with `cargo fmt` 2018-12-08 03:19:47 -08:00
Dale Wijnand 04ddd4d0fc
Upgrade to Rust 2018 2018-12-06 20:18:35 +01:00
Eh2406 e5a11190b3 SourceId is copy, clippy thinks we dont need &SourceId or SourceId.clone() 2018-11-25 21:08:05 -05:00
Carol (Nichols || Goulding) e66c413b86
Support untyped warnings from crates.io with successful publish 2018-11-10 12:46:39 -05:00
Alex Crichton 0b0f089d3d Fix timeouts firing while tarballs are extracted
This commit fixes #6125 by ensuring that while we're extracting tarballs
or doing other synchronous work like grabbing file locks we're not
letting the timeout timers of each HTTP transfer keep ticking. This is
curl's default behavior (which we don't want in this scenario). Instead
the timeout logic is inlined directly and we manually account for the
synchronous work happening not counting towards timeout limits.

Closes #6125
2018-10-12 10:24:29 -07:00
Alex Crichton ba3758134e Add convenience debugging for HTTP requests in Cargo
This is something we probably should have added long long ago given the
number of network issues that arise over time. This adds a new
configuration setting for Cargo, `http.debug`, which activates curl's
`verbose` interface which prints out information like redirects and
headers flying back and forth. This is by default routed through Cargo's
normal debug logging facilities, meaning one way to use this could be:

    CARGO_HTTP_DEBUG=true \
      RUST_LOG=cargo::ops::registry \
      cargo build

and you should get lots of nice verbose logs as a result! This should
hopefully make it much easier to remotely debug HTTP issues as we can in
theory do a lot less guessing and a lot more manual inspection.
2018-10-11 16:55:39 -07:00
Alex Crichton e82443dfd8 Fix publishing renamed dependencies to crates.io
This commit fixes publishing crates which contain locally renamed dependencies
to crates.io. Previously this lack of information meant that although we could
resolve the crate graph correctly it wouldn't work well with respect to optional
features and optional dependencies. The fix here is to persist this information
into the registry about the crate being renamed in `Cargo.toml`, allowing Cargo
to correctly deduce feature names as it does when it has `Cargo.toml` locally.

A dual side of this commit is to publish this information to crates.io. We'll
want to merge the associated PR (link to come soon) on crates.io first and make
sure that's deployed as well before we stabilize the crate renaming feature.

The index format is updated as well as part of this change. The `name` key for
dependencies is now unconditionally what was written in `Cargo.toml` as the
left-hand-side of the dependency specification. In other words this is the raw
crate name, but only for the local crate. A new key, `package`, is added to
dependencies (and it can be `None`). This key indicates the crates.io package is
being linked against, an represents the `package` key in `Cargo.toml`.

It's important to consider the interaction with older Cargo implementations
which don't support the `package` key in the index. In these situations older
Cargo binaries will likely fail to resolve entirely as the renamed name is
unlikely to exist on crates.io. For example the `futures` crate now has an
optional dependency with the name `futures01` which depends on an older version
of `futures` on crates.io. The string `futures01` will be listed in the index
under the `"name"` key, but no `futures01` crate exists on crates.io so older
Cargo will generate an error. If the crate does exist on crates.io, then even
weirder error messages will likely result.

Closes #5962
2018-09-07 09:59:54 -07:00
Marc Schlegel 189f14fe03 Revert removal of default-value for curl low-speed-time
In case no timeout is specified a default value is needed.
2018-09-04 19:16:41 +02:00
Marc Schlegel d6cde29517 Provide http-config option for curl low-speed-limit
Fixes rust-lang/cargo#5717

low-speed-time was removed because the corresponding curl-option is already set via http.timeout.

removed unnecessary Option.
2018-09-03 17:44:07 +02:00
Marc Schlegel 02791238a9 Provide http-config option for curl low-speed-limit/time
Fixes rust-lang/cargo#5717
2018-09-02 00:29:46 +02:00
Alex Crichton 5295caddd5 Use listed dependency name for feature names
This commit updates the implementation of renamed dependencies to use the listed
name of a dependency in Cargo.toml for the name of the associated feature,
rather than using the package name. This'll allow disambiguating between
different packages of the same name and was the intention all along!

Closes #5753
2018-07-31 07:28:53 -07:00
knight42 5e680f2849 Only update the missing registry before search
And update the replaced registry specified in `.cargo/config`
2018-07-23 09:31:40 +08:00
Eh2406 52635fe34c reduce InternedString::new from the hot loop 2018-07-06 17:52:16 -04:00
Aleksey Kladov 39a3709dcc Allow publishing crates with nightly features 2018-06-03 10:25:05 +03:00
DarkDrek ab4b8b9d83 Add option to set user-agent
Fixes #5494
2018-05-12 01:19:00 +02:00
Dirkjan Ochtman cb533ae1bf Take feature namespace into account while building summary (fixes #1286)
Here's an attempt at a table to cover the different cases:

Feature
    Old (must be in features table)
        Continue
    Namespaced (might be stray value)
        In features table: Check that Crate dependency is in the list
        -> Non-optional dependency: Bail [PREVIOUSLY: bailed for non-optional dependency]
        -> Optional dependency: Insert feature of this name
        -> Else: Bail [PREVIOUSLY: bailed for unknown dependency or feature]

Crate
    Old (might be stray value)
        Non-optional dependency: Bail
        No dependency found: Bail
    Namespaced
        Non-optional dependency: Bail
        No dependency found: Bail

CrateFeature
    Old
        No dependency found: Bail
    Namespaced
        No dependency found: Bail
2018-04-28 13:41:18 +02:00
Klaus Purer 947e890249 chore(clippy): Simplify minor stuff found by clippy 2018-04-04 23:08:31 +02:00
Eh2406 5c9d34beaa Intern more strings
cargo +stable fmt
2018-04-04 15:43:26 -04:00
Dirkjan Ochtman 7b542268f5 Introduce FeatureValue enum for tracking feature types 2018-04-04 18:03:40 +02:00
Aleksey Kladov 71073f8b7c Extract common code for dealing with path-valued arguments 2018-03-19 22:47:03 +03:00
Alex Crichton 9659f56032 Remove `Source::for_path`
This commit removes the `Source::for_path` constructor in favor of
`Workspace::load`. This prevents re-parsing manifests multiple times as Cargo
loads up as this can sometimes be an expensive operation. Instead the
`Workspace` now retains a cache of packages that can be updated as it goes
along. Finally, this should mean that we're only parsing path dependencies at
most once rather than multiple times.
2018-03-15 07:34:19 -07:00
Alex Crichton 1e6828485e cargo fmt 2018-03-14 17:48:23 -07:00
Aleksey Kladov 823f1ff32a Validate the limit argument 2018-03-10 18:03:44 +03:00
Aleksey Kladov d8d1f13ba0 Make `target` option owned in various configs 2018-03-10 16:44:43 +03:00
Eh2406 676edacfba some simple clippy things V2 2018-02-26 21:02:39 -05:00
Eh2406 0247dc429a intellij rust suggested fixes
(cherry picked from commit 24836e9)
2018-02-26 17:29:17 -05:00
Eh2406 4d2d444d05 Merge branch 'conflict_tracking' into links
# Conflicts:
#	src/cargo/core/resolver/mod.rs
#	tests/resolve.rs
2018-02-13 17:33:31 -05:00
brotzeit 577b8a2431 apply clippy suggestions 2018-02-06 22:49:50 +01:00
Eh2406 58590ae3c4 Send the links attribute to the registry 2018-01-27 23:01:57 -05:00
Steven Fackler 0ec7f6878c Allow path + registry dependencies
Closes #4843
2018-01-19 22:31:11 -08:00
Steven Fackler c85a43b07e Allow packaging of crates with unstable features
We don't want them to land on crates.io, but it's fine to make a .crate
file.

Closes #4954
2018-01-18 10:35:40 -08:00
bors 3bb05363d2 Auto merge of #4770 - chabapok:master, r=alexcrichton
Add an "-Z offline" flag to Cargo, altering it's dependency resolution behavior

This PR is implementation of the #4686 (without "Populating the global cache" feature)
2018-01-09 15:39:47 +00:00
Steven Fackler 5cb5e7d8f0 Make .cargo/credentials a subset of .cargo/config
Previously, .cargo/credentials looked like

```toml
token = "..."

[my-registry]
token = "..."
```

And was simply merged into the `registry` block of .cargo/config. This
meant that custom registry tokens were under
`registry.my-registry.token` rather than `registries.my-registry.token`
which is where the index was located, and that you couldn't have a
custom registry named `token` or it'd conflict with the token for the
default registry.

This commit changes things such that .cargo/credentials has the same
layout as .cargo/config, but only contains token values. For backwards
compatibility, we move `token` to `registry.token` when parsing.
2018-01-08 15:14:55 -08:00
Pelepeichenko Alexander ec5f78f933 add offline mode (-Z offline) with tests 2018-01-08 21:31:39 +02:00
Alex Crichton 37cffbe0a3 Start migration to the `failure` crate
This commit is the initial steps to migrate Cargo's error handling from the
`error-chain` crate to the `failure` crate. This is intended to be a low-cost
(in terms of diff) transition where possible so it's note "purely idiomatic
`failure` crate" just yet.

The `error-chain` dependency is dropped in this commit and Cargo now canonically
uses the `Error` type from the `failure` crate. The main last remnant of
`error-chain` is a custom local extension trait to use `chain_err` instead of
`with_context`. I'll try to follow up with a commit that renames this later but
I wanted to make sure everything worked first! (and `chain_err` is used
practically everywhere).

Some minor tweaks happened in the tests as I touched up a few error messages
here and there but overall the UI of Cargo should be exactly the same before and
after this commit.
2017-12-18 17:48:36 -08:00
Jake Goulding 9f932e1183 Use the custom HTTP transport when any HTTP settings are present 2017-12-14 13:36:06 -06:00
bors b34bb2337b Auto merge of #4774 - lukaslueg:issue4771, r=alexcrichton
Break crate-descriptions at char-, not byte-boundary, avoiding a panic

Fixes #4771. The basic panicking-problem could be fixed by truncating at `char`- instead of `byte`-boundary. This PR takes the long route and uses the unicode-width to always truncate at grapheme-boundary, which should be visually correct in more cases. It adds two extra (extremely common) dependencies to Cargo, though. I have no strong opinions if this is worth it.

While truncating the descriptions, we now also take the length of the names-column into account, including margin, run a little shorter, and have them all of the same total true length.

Before
```
$ cargo search serde
serde = "1.0.23"                      # A generic serialization/deserialization framework
serde_json = "1.0.7"                  # A JSON serialization file format
serde_derive_internals = "0.17.0"     # AST representation used by Serde derive macros. Unstable.
serde_yaml = "0.7.3"                  # YAML support for Serde
serde_derive = "1.0.23"               # Macros 1.1 implementation of #[derive(Serialize, Deserialize)]
serde_test = "1.0.23"                 # Token De/Serializer for testing De/Serialize implementations
serde_bytes = "0.10.2"                # Optimized handling of `&[u8]` and `Vec<u8>` for Serde
serde_millis = "0.1.1"                #     A serde wrapper that stores integer millisecond value for timestamps     and durations (used similarly to serde_bytes)
serde_codegen_internals = "0.14.2"    # AST representation used by Serde codegen. Unstable.
courier = "0.3.1"                     # Utility to make it easier to send and receive data when using the Rocket framework.
... and 275 crates more (use --limit N to see more)
```

After
```
$ cargo search serde
serde = "1.0.23"                      # A generic serialization/deserialization framework
serde_json = "1.0.7"                  # A JSON serialization file format
serde_derive_internals = "0.17.0"     # AST representation used by Serde derive macros. Unstable.
serde_yaml = "0.7.3"                  # YAML support for Serde
serde_derive = "1.0.23"               # Macros 1.1 implementation of #[derive(Serialize, Deserialize)]
serde_test = "1.0.23"                 # Token De/Serializer for testing De/Serialize implementations
serde_bytes = "0.10.2"                # Optimized handling of `&[u8]` and `Vec<u8>` for Serde
serde_millis = "0.1.1"                #     A serde wrapper that stores integer millisecond value for …
serde_codegen_internals = "0.14.2"    # AST representation used by Serde codegen. Unstable.
courier = "0.3.1"                     # Utility to make it easier to send and receive data when using …
... and 275 crates more (use --limit N to see more)
```
2017-12-05 16:32:16 +00:00
Alex Crichton 5c6086847b Reconfigure curl handles after reset
This'll ensure that all our proxy/speed data/etc will be preserved in the
libcurl configuration

Closes #4779
2017-12-05 07:27:04 -08:00