Skip to content

Commit 04c8191

Browse files
committed
Explain how to work with subrepos
1 parent 1a87c49 commit 04c8191

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

CONTRIBUTING.md

+47-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,53 @@ with one another are rolled up.
188188
Speaking of tests, Rust has a comprehensive test suite. More information about
189189
it can be found [here][rctd].
190190

191-
### External Dependencies
191+
### External Dependencies (subrepo)
192+
193+
As a developer to this repository, you don't have to treat the following external projects
194+
differently from other crates that are directly in this repo:
195+
196+
* none so far, see https://github.com/rust-lang/rust/issues/70651 for more info
197+
198+
They are just regular files and directories. This is in contrast to `submodule` dependencies
199+
(see below for those).
200+
201+
If you want to synchronize or otherwise work with subrepos, install the `git subrepo` command via
202+
instructions found at https://github.com/ingydotnet/git-subrepo
203+
204+
#### Synchronizing a subrepo
205+
206+
There are two synchronization directions: `subrepo push` and `subrepo pull`. Both operations create
207+
a synchronization commit in the rustc repo.
208+
This commit is very important in order to make future synchronizations work.
209+
Do not rebase this commit under any circumstances.
210+
Prefer to merge in case of conflicts or redo the operation if you really need to rebase.
211+
212+
A `git subrepo push src/tools/clippy`
213+
takes all the changes that
214+
happened to the copy in this repo and creates commits on the remote repo that match the local
215+
changes (so every local commit that touched the subrepo causes a commit on the remote repo).
216+
217+
A `git subrepo pull src/tools/clippy` takes all changes since the last `subrepo pull` from the clippy
218+
repo and creates a single commit in the rustc repo with all the changes.
219+
220+
#### Creating a new subrepo dependency
221+
222+
If you want to create a new subrepo dependency from an existing repository, call (from this
223+
repository's root directory!!)
224+
225+
```
226+
git subrepo clone https://github.com/rust-lang/rust-clippy.git src/tools/clippy
227+
```
228+
229+
This will create a new commit, which you may not rebase under any circumstances! Delete the commit
230+
and redo the operation if you need to rebase.
231+
232+
Now you're done, the `src/tools/clippy` directory behaves as if clippy were part of the rustc
233+
monorepo, so no one but you (or others that synchronize subrepos) needs to have `git subrepo`
234+
installed.
235+
236+
237+
### External Dependencies (submodules)
192238

193239
Currently building Rust will also build the following external projects:
194240

@@ -221,7 +267,6 @@ before the PR is merged.
221267

222268
Rust's build system builds a number of tools that make use of the
223269
internals of the compiler. This includes
224-
[Clippy](https://github.com/rust-lang/rust-clippy),
225270
[RLS](https://github.com/rust-lang/rls) and
226271
[rustfmt](https://github.com/rust-lang/rustfmt). If these tools
227272
break because of your changes, you may run into a sort of "chicken and egg"

0 commit comments

Comments
 (0)