Skip to content

Commit 206ec6e

Browse files
committed
Move syncing doc to book
1 parent af38579 commit 206ec6e

File tree

3 files changed

+126
-125
lines changed

3 files changed

+126
-125
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ All contributors are expected to follow the [Rust Code of Conduct].
2121
- [IntelliJ Rust](#intellij-rust)
2222
- [Rust Analyzer](#rust-analyzer)
2323
- [How Clippy works](#how-clippy-works)
24-
- [Syncing changes between Clippy and `rust-lang/rust`](#syncing-changes-between-clippy-and-rust-langrust)
25-
- [Patching git-subtree to work with big repos](#patching-git-subtree-to-work-with-big-repos)
26-
- [Performing the sync from `rust-lang/rust` to Clippy](#performing-the-sync-from-rust-langrust-to-clippy)
27-
- [Performing the sync from Clippy to `rust-lang/rust`](#performing-the-sync-from-clippy-to-rust-langrust)
28-
- [Defining remotes](#defining-remotes)
2924
- [Issue and PR triage](#issue-and-pr-triage)
3025
- [Bors and Homu](#bors-and-homu)
3126
- [Contributions](#contributions)
@@ -205,126 +200,6 @@ That's why the `else_if_without_else` example uses the `register_early_pass` fun
205200
[early_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html
206201
[late_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html
207202

208-
## Syncing changes between Clippy and [`rust-lang/rust`]
209-
210-
Clippy currently gets built with a pinned nightly version.
211-
212-
In the `rust-lang/rust` repository, where rustc resides, there's a copy of Clippy
213-
that compiler hackers modify from time to time to adapt to changes in the unstable
214-
API of the compiler.
215-
216-
We need to sync these changes back to this repository periodically, and the changes
217-
made to this repository in the meantime also need to be synced to the `rust-lang/rust` repository.
218-
219-
To avoid flooding the `rust-lang/rust` PR queue, this two-way sync process is done
220-
in a bi-weekly basis if there's no urgent changes. This is done starting on the day of
221-
the Rust stable release and then every other week. That way we guarantee that we keep
222-
this repo up to date with the latest compiler API, and every feature in Clippy is available
223-
for 2 weeks in nightly, before it can get to beta. For reference, the first sync
224-
following this cadence was performed the 2020-08-27.
225-
226-
This process is described in detail in the following sections. For general information
227-
about `subtree`s in the Rust repository see [Rust's `CONTRIBUTING.md`][subtree].
228-
229-
### Patching git-subtree to work with big repos
230-
231-
Currently, there's a bug in `git-subtree` that prevents it from working properly
232-
with the [`rust-lang/rust`] repo. There's an open PR to fix that, but it's stale.
233-
Before continuing with the following steps, we need to manually apply that fix to
234-
our local copy of `git-subtree`.
235-
236-
You can get the patched version of `git-subtree` from [here][gitgitgadget-pr].
237-
Put this file under `/usr/lib/git-core` (taking a backup of the previous file)
238-
and make sure it has the proper permissions:
239-
240-
```bash
241-
sudo cp --backup /path/to/patched/git-subtree.sh /usr/lib/git-core/git-subtree
242-
sudo chmod --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree
243-
sudo chown --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree
244-
```
245-
246-
_Note:_ The first time running `git subtree push` a cache has to be built. This
247-
involves going through the complete Clippy history once. For this you have to
248-
increase the stack limit though, which you can do with `ulimit -s 60000`.
249-
Make sure to run the `ulimit` command from the same session you call git subtree.
250-
251-
_Note:_ If you are a Debian user, `dash` is the shell used by default for scripts instead of `sh`.
252-
This shell has a hardcoded recursion limit set to 1000. In order to make this process work,
253-
you need to force the script to run `bash` instead. You can do this by editing the first
254-
line of the `git-subtree` script and changing `sh` to `bash`.
255-
256-
### Performing the sync from [`rust-lang/rust`] to Clippy
257-
258-
Here is a TL;DR version of the sync process (all of the following commands have
259-
to be run inside the `rust` directory):
260-
261-
1. Clone the [`rust-lang/rust`] repository or make sure it is up to date.
262-
2. Checkout the commit from the latest available nightly. You can get it using `rustup check`.
263-
3. Sync the changes to the rust-copy of Clippy to your Clippy fork:
264-
```bash
265-
# Make sure to change `your-github-name` to your github name in the following command. Also be
266-
# sure to either use a net-new branch, e.g. `sync-from-rust`, or delete the branch beforehand
267-
# because changes cannot be fast forwarded
268-
git subtree push -P src/tools/clippy git@github.com:your-github-name/rust-clippy sync-from-rust
269-
```
270-
271-
_Note:_ This will directly push to the remote repository. You can also push
272-
to your local copy by replacing the remote address with `/path/to/rust-clippy`
273-
directory.
274-
275-
_Note:_ Most of the time you have to create a merge commit in the
276-
`rust-clippy` repo (this has to be done in the Clippy repo, not in the
277-
rust-copy of Clippy):
278-
```bash
279-
git fetch origin && git fetch upstream
280-
git checkout sync-from-rust
281-
git merge upstream/master
282-
```
283-
4. Open a PR to `rust-lang/rust-clippy` and wait for it to get merged (to
284-
accelerate the process ping the `@rust-lang/clippy` team in your PR and/or
285-
~~annoy~~ ask them in the [Zulip] stream.)
286-
287-
### Performing the sync from Clippy to [`rust-lang/rust`]
288-
289-
All of the following commands have to be run inside the `rust` directory.
290-
291-
1. Make sure Clippy itself is up-to-date by following the steps outlined in the previous
292-
section if necessary.
293-
294-
2. Sync the `rust-lang/rust-clippy` master to the rust-copy of Clippy:
295-
```bash
296-
git checkout -b sync-from-clippy
297-
git subtree pull -P src/tools/clippy https://github.com/rust-lang/rust-clippy master
298-
```
299-
3. Open a PR to [`rust-lang/rust`]
300-
301-
### Defining remotes
302-
303-
You may want to define remotes, so you don't have to type out the remote
304-
addresses on every sync. You can do this with the following commands (these
305-
commands still have to be run inside the `rust` directory):
306-
307-
```bash
308-
# Set clippy-upstream remote for pulls
309-
$ git remote add clippy-upstream https://github.com/rust-lang/rust-clippy
310-
# Make sure to not push to the upstream repo
311-
$ git remote set-url --push clippy-upstream DISABLED
312-
# Set clippy-origin remote to your fork for pushes
313-
$ git remote add clippy-origin git@github.com:your-github-name/rust-clippy
314-
# Set a local remote
315-
$ git remote add clippy-local /path/to/rust-clippy
316-
```
317-
318-
You can then sync with the remote names from above, e.g.:
319-
320-
```bash
321-
$ git subtree push -P src/tools/clippy clippy-local sync-from-rust
322-
```
323-
324-
[gitgitgadget-pr]: https://github.com/gitgitgadget/git/pull/493
325-
[subtree]: https://rustc-dev-guide.rust-lang.org/contributing.html#external-dependencies-subtree
326-
[`rust-lang/rust`]: https://github.com/rust-lang/rust
327-
328203
## Issue and PR triage
329204

330205
Clippy is following the [Rust triage procedure][triage] for issues and pull

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [Adding Lints](development/adding_lints.md)
2323
- [Common Tools](development/common_tools_writing_lints.md)
2424
- [Infrastructure](infrastructure/README.md)
25+
- [Syncing changes between Clippy and rust-lang/rust](infrastructure/sync.md)
2526
- [Backporting Changes](infrastructure/backport.md)
2627
- [Updating the Changelog](infrastructure/changelog_update.md)
2728
- [Release a New Version](infrastructure/release.md)

book/src/infrastructure/sync.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Syncing changes between Clippy and [`rust-lang/rust`]
2+
3+
Clippy currently gets built with a pinned nightly version.
4+
5+
In the `rust-lang/rust` repository, where rustc resides, there's a copy of
6+
Clippy that compiler hackers modify from time to time to adapt to changes in the
7+
unstable API of the compiler.
8+
9+
We need to sync these changes back to this repository periodically, and the
10+
changes made to this repository in the meantime also need to be synced to the
11+
`rust-lang/rust` repository.
12+
13+
To avoid flooding the `rust-lang/rust` PR queue, this two-way sync process is
14+
done in a bi-weekly basis if there's no urgent changes. This is done starting on
15+
the day of the Rust stable release and then every other week. That way we
16+
guarantee that we keep this repo up to date with the latest compiler API, and
17+
every feature in Clippy is available for 2 weeks in nightly, before it can get
18+
to beta. For reference, the first sync following this cadence was performed the
19+
2020-08-27.
20+
21+
This process is described in detail in the following sections. For general
22+
information about `subtree`s in the Rust repository see [Rust's
23+
`CONTRIBUTING.md`][subtree].
24+
25+
## Patching git-subtree to work with big repos
26+
27+
Currently, there's a bug in `git-subtree` that prevents it from working properly
28+
with the [`rust-lang/rust`] repo. There's an open PR to fix that, but it's
29+
stale. Before continuing with the following steps, we need to manually apply
30+
that fix to our local copy of `git-subtree`.
31+
32+
You can get the patched version of `git-subtree` from [here][gitgitgadget-pr].
33+
Put this file under `/usr/lib/git-core` (making a backup of the previous file)
34+
and make sure it has the proper permissions:
35+
36+
```bash
37+
sudo cp --backup /path/to/patched/git-subtree.sh /usr/lib/git-core/git-subtree
38+
sudo chmod --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree
39+
sudo chown --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree
40+
```
41+
42+
> _Note:_ The first time running `git subtree push` a cache has to be built.
43+
> This involves going through the complete Clippy history once. For this you
44+
> have to increase the stack limit though, which you can do with `ulimit -s
45+
> 60000`. Make sure to run the `ulimit` command from the same session you call
46+
> git subtree.
47+
48+
> _Note:_ If you are a Debian user, `dash` is the shell used by default for
49+
> scripts instead of `sh`. This shell has a hardcoded recursion limit set to
50+
> 1000. In order to make this process work, you need to force the script to run
51+
> `bash` instead. You can do this by editing the first line of the `git-subtree`
52+
> script and changing `sh` to `bash`.
53+
54+
## Performing the sync from [`rust-lang/rust`] to Clippy
55+
56+
Here is a TL;DR version of the sync process (all of the following commands have
57+
to be run inside the `rust` directory):
58+
59+
1. Clone the [`rust-lang/rust`] repository or make sure it is up to date.
60+
2. Checkout the commit from the latest available nightly. You can get it using
61+
`rustup check`.
62+
3. Sync the changes to the rust-copy of Clippy to your Clippy fork:
63+
```bash
64+
# Make sure to change `your-github-name` to your github name in the following command. Also be
65+
# sure to either use a net-new branch, e.g. `sync-from-rust`, or delete the branch beforehand
66+
# because changes cannot be fast forwarded and you have to run this command again.
67+
git subtree push -P src/tools/clippy git@github.com:your-github-name/rust-clippy sync-from-rust
68+
```
69+
70+
> _Note:_ This will directly push to the remote repository. You can also
71+
> push to your local copy by replacing the remote address with
72+
> `/path/to/rust-clippy` directory.
73+
74+
> _Note:_ Most of the time you have to create a merge commit in the
75+
> `rust-clippy` repo (this has to be done in the Clippy repo, not in the
76+
> rust-copy of Clippy):
77+
```bash
78+
git fetch upstream # assuming upstream is the rust-lang/rust remote
79+
git checkout sync-from-rust
80+
git merge upstream/master
81+
```
82+
4. Open a PR to `rust-lang/rust-clippy` and wait for it to get merged (to
83+
accelerate the process ping the `@rust-lang/clippy` team in your PR and/or
84+
ask them in the [Zulip] stream.)
85+
86+
[Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/clippy
87+
88+
## Performing the sync from Clippy to [`rust-lang/rust`]
89+
90+
All of the following commands have to be run inside the `rust` directory.
91+
92+
1. Make sure you have checked out the latest `master` of `rust-lang/rust`.
93+
2. Sync the `rust-lang/rust-clippy` master to the rust-copy of Clippy:
94+
```bash
95+
git checkout -b sync-from-clippy
96+
git subtree pull -P src/tools/clippy https://github.com/rust-lang/rust-clippy master
97+
```
98+
3. Open a PR to [`rust-lang/rust`]
99+
100+
## Defining remotes
101+
102+
You may want to define remotes, so you don't have to type out the remote
103+
addresses on every sync. You can do this with the following commands (these
104+
commands still have to be run inside the `rust` directory):
105+
106+
```bash
107+
# Set clippy-upstream remote for pulls
108+
$ git remote add clippy-upstream https://github.com/rust-lang/rust-clippy
109+
# Make sure to not push to the upstream repo
110+
$ git remote set-url --push clippy-upstream DISABLED
111+
# Set clippy-origin remote to your fork for pushes
112+
$ git remote add clippy-origin git@github.com:your-github-name/rust-clippy
113+
# Set a local remote
114+
$ git remote add clippy-local /path/to/rust-clippy
115+
```
116+
117+
You can then sync with the remote names from above, e.g.:
118+
119+
```bash
120+
$ git subtree push -P src/tools/clippy clippy-local sync-from-rust
121+
```
122+
123+
[gitgitgadget-pr]: https://github.com/gitgitgadget/git/pull/493
124+
[subtree]: https://rustc-dev-guide.rust-lang.org/contributing.html#external-dependencies-subtree
125+
[`rust-lang/rust`]: https://github.com/rust-lang/rust

0 commit comments

Comments
 (0)