Skip to content

Commit

Permalink
Swap out some outdated repo urls in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 31, 2021
1 parent c227565 commit 05f6604
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/cargo/util/canonical_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl CanonicalUrl {
pub fn new(url: &Url) -> CargoResult<CanonicalUrl> {
let mut url = url.clone();

// cannot-be-a-base-urls (e.g., `github.com:rust-lang-nursery/rustfmt.git`)
// cannot-be-a-base-urls (e.g., `github.com:rust-lang/rustfmt.git`)
// are not supported.
if url.cannot_be_a_base() {
anyhow::bail!(
Expand Down
26 changes: 13 additions & 13 deletions src/doc/src/guide/cargo-toml-vs-cargo-lock.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ name = "hello_world"
version = "0.1.0"

[dependencies]
rand = { git = "https://github.com/rust-lang-nursery/rand.git" }
regex = { git = "https://github.com/rust-lang/regex.git" }
```

This package has a single dependency, on the `rand` library. We’ve stated in
This package has a single dependency, on the `regex` library. We’ve stated in
this case that we’re relying on a particular Git repository that lives on
GitHub. Since we haven’t specified any other information, Cargo assumes that
we intend to use the latest commit on the `master` branch to build our package.

Sound good? Well, there’s one problem: If you build this package today, and
then you send a copy to me, and I build this package tomorrow, something bad
could happen. There could be more commits to `rand` in the meantime, and my
could happen. There could be more commits to `regex` in the meantime, and my
build would include new commits while yours would not. Therefore, we would
get different builds. This would be bad because we want reproducible builds.

We could fix this problem by putting a `rev` line in our `Cargo.toml`:

```toml
[dependencies]
rand = { git = "https://github.com/rust-lang-nursery/rand.git", rev = "9f35b8e" }
regex = { git = "https://github.com/rust-lang/regex.git", rev = "9f9f693" }
```

Now our builds will be the same. But there’s a big drawback: now we have to
Expand All @@ -64,7 +64,7 @@ name = "hello_world"
version = "0.1.0"

[dependencies]
rand = { git = "https://github.com/rust-lang-nursery/rand.git" }
regex = { git = "https://github.com/rust-lang/regex.git" }
```

Cargo will take the latest commit and write that information out into our
Expand All @@ -75,13 +75,13 @@ Cargo will take the latest commit and write that information out into our
name = "hello_world"
version = "0.1.0"
dependencies = [
"rand 0.1.0 (git+https://github.com/rust-lang-nursery/rand.git#9f35b8e439eeedd60b9414c58f389bdc6a3284f9)",
"regex 1.5.0 (git+https://github.com/rust-lang/regex.git#9f9f693768c584971a4d53bc3c586c33ed3a6831)",
]

[[package]]
name = "rand"
version = "0.1.0"
source = "git+https://github.com/rust-lang-nursery/rand.git#9f35b8e439eeedd60b9414c58f389bdc6a3284f9"
name = "regex"
version = "1.5.0"
source = "git+https://github.com/rust-lang/regex.git#9f9f693768c584971a4d53bc3c586c33ed3a6831"
```

You can see that there’s a lot more information here, including the exact
Expand All @@ -93,14 +93,14 @@ When we’re ready to opt in to a new version of the library, Cargo can
re-calculate the dependencies and update things for us:

```console
$ cargo update # updates all dependencies
$ cargo update -p rand # updates just “rand
$ cargo update # updates all dependencies
$ cargo update -p regex # updates just “regex
```

This will write out a new `Cargo.lock` with the new version information. Note
that the argument to `cargo update` is actually a
[Package ID Specification](../reference/pkgid-spec.md) and `rand` is just a short
specification.
[Package ID Specification](../reference/pkgid-spec.md) and `regex` is just a
short specification.

[def-manifest]: ../appendix/glossary.md#manifest '"manifest" (glossary entry)'
[def-package]: ../appendix/glossary.md#package '"package" (glossary entry)'
2 changes: 1 addition & 1 deletion src/doc/src/guide/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ currently has no tests:

```console
$ cargo test
Compiling rand v0.1.0 (https://github.com/rust-lang-nursery/rand.git#9f35b8e)
Compiling regex v1.5.0 (https://github.com/rust-lang/regex.git#9f9f693)
Compiling hello_world v0.1.0 (file:///path/to/package/hello_world)
Running target/test/hello_world-9c2b65bbb79eabce

Expand Down
8 changes: 4 additions & 4 deletions src/doc/src/guide/working-on-an-existing-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
If you download an existing [package][def-package] that uses Cargo, it’s
really easy to get going.

First, get the package from somewhere. In this example, we’ll use `rand`
First, get the package from somewhere. In this example, we’ll use `regex`
cloned from its repository on GitHub:

```console
$ git clone https://github.com/rust-lang-nursery/rand.git
$ cd rand
$ git clone https://github.com/rust-lang/regex.git
$ cd regex
```

To build, use `cargo build`:

```console
$ cargo build
Compiling rand v0.1.0 (file:///path/to/package/rand)
Compiling regex v1.5.0 (file:///path/to/package/regex)
```

This will fetch all of the dependencies and then build them, along with the
Expand Down
4 changes: 2 additions & 2 deletions src/doc/src/reference/specifying-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ you need to specify is the location of the repository with the `git` key:

```toml
[dependencies]
rand = { git = "https://github.com/rust-lang-nursery/rand" }
regex = { git = "https://github.com/rust-lang/regex" }
```

Cargo will fetch the `git` repository at this location then look for a
Expand All @@ -144,7 +144,7 @@ the latest commit on a branch named `next`:

```toml
[dependencies]
rand = { git = "https://github.com/rust-lang-nursery/rand", branch = "next" }
regex = { git = "https://github.com/rust-lang/regex", branch = "next" }
```

Once a `git` dependency has been added, Cargo will lock that dependency to the
Expand Down
8 changes: 5 additions & 3 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,10 +1265,12 @@ but cannot be used multiple times

#[cargo_test]
fn test_install_git_cannot_be_a_base_url() {
cargo_process("install --git github.com:rust-lang-nursery/rustfmt.git")
cargo_process("install --git github.com:rust-lang/rustfmt.git")
.with_status(101)
.with_stderr("\
[ERROR] invalid url `github.com:rust-lang-nursery/rustfmt.git`: cannot-be-a-base-URLs are not supported")
.with_stderr(
"\
[ERROR] invalid url `github.com:rust-lang/rustfmt.git`: cannot-be-a-base-URLs are not supported",
)
.run();
}

Expand Down

0 comments on commit 05f6604

Please sign in to comment.