Skip to content

Commit

Permalink
Merge pull request #307 from Nilstrieb/default-github
Browse files Browse the repository at this point in the history
Default to `--access github`
  • Loading branch information
oli-obk committed Jan 28, 2024
2 parents a825626 + d8562d0 commit 2404de6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
44 changes: 22 additions & 22 deletions guide/src/rust-src-repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,30 @@
For `cargo-bisect-rustc` to work, it needs to be able to read the git log of the [`rust-lang/rust`] repo.
`cargo-bisect-rustc` supports several methods for this described below.

## GitHub API

By default, `cargo-bisect-rustc` uses the GitHub API to fetch the information instead of using a local checkout.

```sh
cargo bisect-rustc --access=github
```

Beware that GitHub has restrictive rate limits for unauthenticated requests.
It allows 60 requests per hour, and `cargo-bisect-rustc` will use about 10 requests each time you run it (which can vary depending on the bisection).
If you run into the rate limit, you can raise it to 5000 requests per hour by setting the `GITHUB_TOKEN` environment variable to a [GitHub personal token].
If you use the [`gh` CLI tool], you can use it to get a token:

```sh
GITHUB_TOKEN=`gh auth token` cargo bisect-rustc --access=github
```

If you don't use `gh`, you'll just need to copy and paste the token.

## Local clone

By default, `cargo-bisect-rustc` will clone the rust repo in the current directory (as `rust.git`).
This option can be quite slow, but doesn't require any setup.
`cargo-bisect-rustc` can also clone the rust repo in the current directory (as `rust.git`).
This option can be quite slow if you don't specify the repo path at build time.
You can specify this with the `--access` CLI argument:

## `RUST_SRC_REPO` environment variable

Expand All @@ -26,26 +46,6 @@ This is recommended if you already have the rust repo checked out somewhere.
RUST_SRC_REPO=/path/to/rust cargo install cargo-bisect-rustc
```

## GitHub API

`cargo-bisect-rustc` can use the GitHub API to fetch the information instead of using a local checkout.
You can specify this with the `--access` CLI argument:

```sh
cargo bisect-rustc --access=github
```

Beware that GitHub has restrictive rate limits for unauthenticated requests.
It allows 60 requests per hour, and `cargo-bisect-rustc` will use about 10 requests each time you run it (which can vary depending on the bisection).
If you run into the rate limit, you can raise it to 5000 requests per hour by setting the `GITHUB_TOKEN` environment variable to a [GitHub personal token].
If you use the [`gh` CLI tool], you can use it to get a token:

```sh
GITHUB_TOKEN=`gh auth token` cargo bisect-rustc --access=github
```

If you don't use `gh`, you'll just need to copy and paste the token.

[`rust-lang/rust`]: https://github.com/rust-lang/rust/
[GitHub personal token]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
[`gh` CLI tool]: https://cli.github.com/
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ a date (YYYY-MM-DD), git tag name (e.g. 1.58.0) or git commit SHA."
#[arg(long, help = "Bisect via commit artifacts")]
by_commit: bool,

#[arg(long, value_enum, help = "How to access Rust git repository", default_value_t = Access::Checkout)]
#[arg(long, value_enum, help = "How to access Rust git repository", default_value_t = Access::Github)]
access: Access,

#[arg(long, help = "Install the given artifact")]
Expand Down
2 changes: 1 addition & 1 deletion tests/cmd/h.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Arguments:

Options:
-a, --alt Download the alt build instead of normal build
--access <ACCESS> How to access Rust git repository [default: checkout] [possible
--access <ACCESS> How to access Rust git repository [default: github] [possible
values: checkout, github]
--by-commit Bisect via commit artifacts
-c, --component <COMPONENTS> additional components to install
Expand Down
2 changes: 1 addition & 1 deletion tests/cmd/help.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Options:
--access <ACCESS>
How to access Rust git repository

[default: checkout]
[default: github]
[possible values: checkout, github]

--by-commit
Expand Down

0 comments on commit 2404de6

Please sign in to comment.