Skip to content

Rename tool to rustc-josh-sync and add a few fixes #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "josh-sync"
name = "rustc-josh-sync"
version = "0.1.0"
edition = "2024"

[[bin]]
path = "src/bin/josh_sync.rs"
name = "josh-sync"
path = "src/bin/rustc_josh_sync.rs"
name = "rustc-josh-sync"

[dependencies]
anyhow = "1"
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ This repository contains a binary utility for performing [Josh](https://github.c
synchronizations (pull and push) of Josh subtrees in the [rust-lang/rust](https://github.com/rust-lang/rust) repository.

## Installation
You can install the binary `josh-sync` tool using the following command:
You can install the binary `rustc-josh-sync` tool using the following command:

```bash
$ cargo install --locked --git https://github.com/rust-lang/josh-sync
```

## Creating config file

First, create a configuration file for a given subtree repo using `josh-sync init`. The config will be created under the path `josh-sync.toml`. Modify the file to fill in the name of the subtree repository (e.g. `stdarch`) and its relative path in the main `rust-lang/rust` repository (e.g. `library/stdarch`).
First, create a configuration file for a given subtree repo using `rustc-josh-sync init`. The config will be created under the path `josh-sync.toml`. Modify the file to fill in the name of the subtree repository (e.g. `stdarch`) and its relative path in the main `rust-lang/rust` repository (e.g. `library/stdarch`).

If you need to specify a more complex Josh `filter`, use `filter` field in the configuration file instead of the `path` field.

The `init` command will also create an empty `rust-version` file that stores the last upstream `rustc` SHA that was synced in the subtree.
The `init` command will also create an empty `rust-version` file (if it doesn't already exist) that stores the last upstream `rustc` SHA that was synced in the subtree.

## Performing pull

A pull operation fetches changes to the subtree subdirectory that were performed in `rust-lang/rust` and merges them into the subtree repository. After performing a pull, a pull request is sent against the *subtree repository*. We *pull from rustc*.

1) Checkout the latest default branch of the subtree
2) Create a new branch that will be used for the subtree PR, e.g. `pull`
3) Run `josh-sync pull`
3) Run `rustc-josh-sync pull`
4) Send a PR to the subtree repository
- Note that `josh-sync` can do this for you if you have the [gh](https://cli.github.com/) CLI tool installed.
- Note that `rustc-josh-sync` can do this for you if you have the [gh](https://cli.github.com/) CLI tool installed.

## Performing push

A push operation takes changes performed in the subtree repository and merges them into the subtree subdirectory of the `rust-lang/rust` repository. After performing a push, a push request is sent against the *rustc repository*. We *push to rustc*.

1) Checkout the latest default branch of the subtree
2) Run `josh-sync pull <your-github-username> <branch>`
2) Run `rustc-josh-sync pull <your-github-username> <branch>`
- The branch with the push contents will be created in `https://github.com/<your-github-username>/rust` fork, in the `<branch>` branch.
3) Send a PR to `rustc`

Expand All @@ -56,5 +56,5 @@ You may observe "Nothing to pull" even if you *know* rustc-pull has something to
To minimize the likelihood of this happening, you may wish to keep a separate *minimal* git config that *only* has `[user]` entries from global git config, then repoint system git to use the minimal git config instead. E.g.

```
GIT_CONFIG_GLOBAL=/path/to/minimal/gitconfig GIT_CONFIG_SYSTEM='' josh-sync ...
GIT_CONFIG_GLOBAL=/path/to/minimal/gitconfig GIT_CONFIG_SYSTEM='' rustc-josh-sync ...
```
9 changes: 8 additions & 1 deletion josh-sync.example.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
org = "rust-lang"
# GitHub org of the repository (optional, `rust-lang` is the default)
#org = "rust-lang"
# Name of the repository
repo = "stdarch"
# Path where the subtree is located in rust-lang/rust
path = "library/stdarch"

# Optionally, you can specify the complete Josh filter for complex cases
# Note that this option is mutually exclusive with `path`
#filter = ...
11 changes: 8 additions & 3 deletions src/bin/josh_sync.rs → src/bin/rustc_josh_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ fn main() -> anyhow::Result<()> {
.write(Path::new(DEFAULT_CONFIG_PATH))
.context("cannot write config")?;
println!("Created config file at {DEFAULT_CONFIG_PATH}");
std::fs::write(DEFAULT_RUST_VERSION_PATH, "")
.context("cannot write rust-version file")?;
println!("Created empty rust-version file at {DEFAULT_RUST_VERSION_PATH}");

if !Path::new(DEFAULT_RUST_VERSION_PATH).is_file() {
std::fs::write(DEFAULT_RUST_VERSION_PATH, "")
.context("cannot write rust-version file")?;
println!("Created empty rust-version file at {DEFAULT_RUST_VERSION_PATH}");
} else {
println!("{DEFAULT_RUST_VERSION_PATH} already exists, not doing anything with it");
}
}
Command::Pull {
config_path,
Expand Down