Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #9859 - dtolnay-contrib:pullrequest, r=ehuss
rev = "refs/pull/𑑛/head" GitHub exposes a named reference associated with the head of every pull request. For example, you can fetch *this* pull request: ```console $ git fetch origin refs/pull/9859/head $ git show FETCH_HEAD ``` Usually when I care about pulling in a patch of one of my dependencies using `[patch.crates-io]`, this is the ref that I want to depend on. None of the alternatives are good: - `{ git = "the fork", branch = "the-pr-branch" }` — this is second closest to what I want, except that when the PR merges and the PR author deletes their fork, it'll breaks. - `{ git = "the fork", rev = "commithash" }` — same failure mode as the previous. Also doesn't stay up to date with PR, which is sometimes what I want. - `{ git = "the upstream", rev = "commithash" }` — doesn't work until the PR is merged or the repo owner creates a named branch or tag containing the PR commit among its ancestors, because otherwise the commit doesn't participate in Cargo's fetch. - `{ git = "my own fork of PR author's repo", branch = "the-pr-branch" }` — doesn't stay up to date with PR. This PR adds support for specifying a git dependency on the head of a pull request via the existing `rev` setting of git dependencies: `{ git = "the upstream", rev = "refs/pull/9859/head" }`. Previously this would fail because the `cargo::sources::git::fetch` function touched in this pull request did not fetch the refspec that we care about. The failures look like: ```console error: failed to get `mockall` as a dependency of package `testing v0.0.0` Caused by: failed to load source for dependency `mockall` Caused by: Unable to update https://github.com/asomers/mockall?rev=refs/pull/330/head Caused by: revspec 'refs/pull/330/head' not found; class=Reference (4); code=NotFound (-3) ``` If dual purposing `rev` for this is not appealing, I would alternatively propose `{ git = "the upstream", pull-request = "9859" }` which Cargo will interpret using GitHub's ref naming convention as `refs/pull/9859/head`.
- Loading branch information