Skip to content

Commit 42741e4

Browse files
authored
Merge pull request #2 from rust-lang/fixes
Rename tool to `rustc-josh-sync` and add a few fixes
2 parents b95c34e + 6433621 commit 42741e4

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
2-
name = "josh-sync"
2+
name = "rustc-josh-sync"
33
version = "0.1.0"
44
edition = "2024"
55

66
[[bin]]
7-
path = "src/bin/josh_sync.rs"
8-
name = "josh-sync"
7+
path = "src/bin/rustc_josh_sync.rs"
8+
name = "rustc-josh-sync"
99

1010
[dependencies]
1111
anyhow = "1"

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@ This repository contains a binary utility for performing [Josh](https://github.c
33
synchronizations (pull and push) of Josh subtrees in the [rust-lang/rust](https://github.com/rust-lang/rust) repository.
44

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

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

1212
## Creating config file
1313

14-
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`).
14+
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`).
1515

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

18-
The `init` command will also create an empty `rust-version` file that stores the last upstream `rustc` SHA that was synced in the subtree.
18+
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.
1919

2020
## Performing pull
2121

2222
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*.
2323

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

3030
## Performing push
3131

3232
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*.
3333

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

@@ -56,5 +56,5 @@ You may observe "Nothing to pull" even if you *know* rustc-pull has something to
5656
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.
5757

5858
```
59-
GIT_CONFIG_GLOBAL=/path/to/minimal/gitconfig GIT_CONFIG_SYSTEM='' josh-sync ...
59+
GIT_CONFIG_GLOBAL=/path/to/minimal/gitconfig GIT_CONFIG_SYSTEM='' rustc-josh-sync ...
6060
```

josh-sync.example.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
org = "rust-lang"
1+
# GitHub org of the repository (optional, `rust-lang` is the default)
2+
#org = "rust-lang"
3+
# Name of the repository
24
repo = "stdarch"
5+
# Path where the subtree is located in rust-lang/rust
36
path = "library/stdarch"
7+
8+
# Optionally, you can specify the complete Josh filter for complex cases
9+
# Note that this option is mutually exclusive with `path`
10+
#filter = ...

src/bin/josh_sync.rs renamed to src/bin/rustc_josh_sync.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,14 @@ fn main() -> anyhow::Result<()> {
5757
.write(Path::new(DEFAULT_CONFIG_PATH))
5858
.context("cannot write config")?;
5959
println!("Created config file at {DEFAULT_CONFIG_PATH}");
60-
std::fs::write(DEFAULT_RUST_VERSION_PATH, "")
61-
.context("cannot write rust-version file")?;
62-
println!("Created empty rust-version file at {DEFAULT_RUST_VERSION_PATH}");
60+
61+
if !Path::new(DEFAULT_RUST_VERSION_PATH).is_file() {
62+
std::fs::write(DEFAULT_RUST_VERSION_PATH, "")
63+
.context("cannot write rust-version file")?;
64+
println!("Created empty rust-version file at {DEFAULT_RUST_VERSION_PATH}");
65+
} else {
66+
println!("{DEFAULT_RUST_VERSION_PATH} already exists, not doing anything with it");
67+
}
6368
}
6469
Command::Pull {
6570
config_path,

0 commit comments

Comments
 (0)