Skip to content

Commit ded114b

Browse files
committed
Add tooling for josh syncs
Create a crate that handles pulling from and pushing to rust-lang/rust. This can be invoked with the following: $ cargo run -p josh-sync -- rustc-pull $ RUSTC_GIT=/path/to/rust/checkout cargo run -p josh-sync -- rustc-push <username>
1 parent 9e0cc1d commit ded114b

File tree

4 files changed

+424
-0
lines changed

4 files changed

+424
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resolver = "2"
33
members = [
44
"builtins-test",
55
"compiler-builtins",
6+
"crates/josh-sync",
67
"crates/libm-macros",
78
"crates/musl-math-sys",
89
"crates/panic-handler",

crates/josh-sync/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "josh-sync"
3+
edition = "2024"
4+
publish = false
5+
6+
[dependencies]
7+
directories = "6.0.0"

crates/josh-sync/src/main.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use std::io::{Read, Write};
2+
use std::process::exit;
3+
use std::{env, io};
4+
5+
use crate::sync::{GitSync, Josh};
6+
7+
mod sync;
8+
9+
const USAGE: &str = r#"Utility for synchroniing compiler-builtins with rust-lang/rust
10+
11+
Usage:
12+
13+
josh-sync rustc-pull
14+
15+
Pull from rust-lang/rust to compiler-builtins. Creates a commit
16+
updating the version file, followed by a merge commit.
17+
18+
josh-sync rustc-push GITHUB_USERNAME [BRANCH]
19+
20+
Create a branch off of rust-lang/rust updating compiler-builtins.
21+
"#;
22+
23+
fn main() {
24+
let sync = GitSync::from_current_dir();
25+
26+
// Collect args, then recollect as str refs so we can match on them
27+
let args: Vec<_> = env::args().collect();
28+
let args: Vec<&str> = args.iter().map(String::as_str).collect();
29+
30+
match args.as_slice()[1..] {
31+
["rustc-pull"] => sync.rustc_pull(None),
32+
["rustc-push", github_user, branch] => sync.rustc_push(github_user, Some(branch)),
33+
["rustc-push", github_user] => sync.rustc_push(github_user, None),
34+
["start-josh"] => {
35+
let _josh = Josh::start();
36+
println!("press enter to stop");
37+
io::stdout().flush().unwrap();
38+
let _ = io::stdin().read(&mut [0u8]).unwrap();
39+
}
40+
_ => {
41+
println!("{USAGE}");
42+
exit(1);
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)