Skip to content

Commit 00f99eb

Browse files
committed
new sync location
1 parent bda0ee2 commit 00f99eb

File tree

1 file changed

+54
-25
lines changed

1 file changed

+54
-25
lines changed

josh-sync/src/sync.rs

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
use anyhow::{anyhow, bail, Context};
2+
use std::io::Write;
13
use std::ops::Not;
24
use std::path::PathBuf;
3-
use std::{env, net, process};
4-
use std::io::Write;
55
use std::time::Duration;
6-
use anyhow::{anyhow, bail, Context};
6+
use std::{env, net, process};
77
use xshell::{cmd, Shell};
88

99
/// Used for rustc syncs.
10-
const JOSH_FILTER: &str = ":/src/doc/rustc-dev-guide";
10+
const JOSH_FILTER: &str = ":/src/doc/rustc-dev-guide2";
1111
const JOSH_PORT: u16 = 42042;
12-
const UPSTREAM_REPO: &str = "rust-lang/rust";
12+
const UPSTREAM_REPO: &str = "BoxyUwU/rust";
1313

1414
pub struct GitSync {
1515
dir: PathBuf,
@@ -20,7 +20,7 @@ pub struct GitSync {
2020
impl GitSync {
2121
pub fn from_current_dir() -> anyhow::Result<Self> {
2222
Ok(Self {
23-
dir: std::env::current_dir()?
23+
dir: std::env::current_dir()?,
2424
})
2525
}
2626

@@ -37,7 +37,11 @@ impl GitSync {
3737
.ok_or_else(|| anyhow!("Could not obtain Rust repo HEAD from remote."))
3838
})?;
3939
// Make sure the repo is clean.
40-
if cmd!(sh, "git status --untracked-files=no --porcelain").read()?.is_empty().not() {
40+
if cmd!(sh, "git status --untracked-files=no --porcelain")
41+
.read()?
42+
.is_empty()
43+
.not()
44+
{
4145
bail!("working directory must be clean before performing rustc pull");
4246
}
4347
// Make sure josh is running.
@@ -52,9 +56,12 @@ impl GitSync {
5256
// the right rust-version file while resolving them.
5357
sh.write_file("rust-version", format!("{commit}\n"))?;
5458
const PREPARING_COMMIT_MESSAGE: &str = "Preparing for merge from rustc";
55-
cmd!(sh, "git commit rust-version --no-verify -m {PREPARING_COMMIT_MESSAGE}")
56-
.run()
57-
.context("FAILED to commit rust-version file, something went wrong")?;
59+
cmd!(
60+
sh,
61+
"git commit rust-version --no-verify -m {PREPARING_COMMIT_MESSAGE}"
62+
)
63+
.run()
64+
.context("FAILED to commit rust-version file, something went wrong")?;
5865

5966
// Fetch given rustc commit.
6067
cmd!(sh, "git fetch {josh_url}")
@@ -78,9 +85,12 @@ impl GitSync {
7885

7986
// Merge the fetched commit.
8087
const MERGE_COMMIT_MESSAGE: &str = "Merge from rustc";
81-
cmd!(sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}")
82-
.run()
83-
.context("FAILED to merge new commits, something went wrong")?;
88+
cmd!(
89+
sh,
90+
"git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}"
91+
)
92+
.run()
93+
.context("FAILED to merge new commits, something went wrong")?;
8494

8595
// Check that the number of roots did not increase.
8696
if num_roots()? != num_roots_before {
@@ -96,7 +106,11 @@ impl GitSync {
96106
sh.change_dir(&self.dir);
97107
let base = sh.read_file("rust-version")?.trim().to_owned();
98108
// Make sure the repo is clean.
99-
if cmd!(sh, "git status --untracked-files=no --porcelain").read()?.is_empty().not() {
109+
if cmd!(sh, "git status --untracked-files=no --porcelain")
110+
.read()?
111+
.is_empty()
112+
.not()
113+
{
100114
bail!("working directory must be clean before running `rustc-push`");
101115
}
102116
// Make sure josh is running.
@@ -127,21 +141,27 @@ impl GitSync {
127141
// the commit that we pulled from last time, so we use the `rust-version`
128142
// file to find out which commit that would be.
129143
println!("Preparing {github_user}/rust (base: {base})...");
130-
if cmd!(sh, "git fetch https://github.com/{github_user}/rust {branch}")
131-
.ignore_stderr()
132-
.read()
133-
.is_ok()
144+
if cmd!(
145+
sh,
146+
"git fetch https://github.com/{github_user}/rust {branch}"
147+
)
148+
.ignore_stderr()
149+
.read()
150+
.is_ok()
134151
{
135152
println!(
136153
"The branch '{branch}' seems to already exist in 'https://github.com/{github_user}/rust'. Please delete it and try again."
137154
);
138155
std::process::exit(1);
139156
}
140157
cmd!(sh, "git fetch https://github.com/{UPSTREAM_REPO} {base}").run()?;
141-
cmd!(sh, "git push https://github.com/{github_user}/rust {base}:refs/heads/{branch}")
142-
.ignore_stdout()
143-
.ignore_stderr() // silence the "create GitHub PR" message
144-
.run()?;
158+
cmd!(
159+
sh,
160+
"git push https://github.com/{github_user}/rust {base}:refs/heads/{branch}"
161+
)
162+
.ignore_stdout()
163+
.ignore_stderr() // silence the "create GitHub PR" message
164+
.run()?;
145165
println!();
146166

147167
// Do the actual push.
@@ -151,7 +171,9 @@ impl GitSync {
151171
println!();
152172

153173
// Do a round-trip check to make sure the push worked as expected.
154-
cmd!(sh, "git fetch {josh_url} {branch}").ignore_stderr().read()?;
174+
cmd!(sh, "git fetch {josh_url} {branch}")
175+
.ignore_stderr()
176+
.read()?;
155177
let head = cmd!(sh, "git rev-parse HEAD").read()?;
156178
let fetch_head = cmd!(sh, "git rev-parse FETCH_HEAD").read()?;
157179
if head != fetch_head {
@@ -188,7 +210,9 @@ impl GitSync {
188210
cmd.arg("--no-background");
189211
cmd.stdout(process::Stdio::null());
190212
cmd.stderr(process::Stdio::null());
191-
let josh = cmd.spawn().context("failed to start josh-proxy, make sure it is installed")?;
213+
let josh = cmd
214+
.spawn()
215+
.context("failed to start josh-proxy, make sure it is installed")?;
192216

193217
// Create a wrapper that stops it on drop.
194218
struct Josh(process::Child);
@@ -204,7 +228,12 @@ impl GitSync {
204228
// Sadly there is no "wait with timeout"... so we just give it some time to finish.
205229
std::thread::sleep(Duration::from_millis(100));
206230
// Now hopefully it is gone.
207-
if self.0.try_wait().expect("failed to wait for josh-proxy").is_some() {
231+
if self
232+
.0
233+
.try_wait()
234+
.expect("failed to wait for josh-proxy")
235+
.is_some()
236+
{
208237
return;
209238
}
210239
}

0 commit comments

Comments
 (0)