Skip to content

Commit 5e2a659

Browse files
committed
"cargo fmt"
1 parent 9f710fd commit 5e2a659

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

josh-sync/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clap::Parser;
2+
23
use crate::sync::{GitSync, RustcPullError};
34

45
mod sync;
@@ -11,10 +12,7 @@ enum Args {
1112
/// Push changes from `rustc-dev-guide` to the given `branch` of a `rustc` fork under the given
1213
/// GitHub `username`.
1314
/// The pushed branch should then be merged into the `rustc` repository.
14-
RustcPush {
15-
branch: String,
16-
github_username: String
17-
}
15+
RustcPush { branch: String, github_username: String },
1816
}
1917

2018
fn main() -> anyhow::Result<()> {

josh-sync/src/sync.rs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
use std::io::Write;
12
use std::ops::Not;
23
use std::path::PathBuf;
3-
use std::{env, net, process};
4-
use std::io::Write;
54
use std::time::Duration;
6-
use anyhow::{anyhow, bail, Context};
7-
use xshell::{cmd, Shell};
5+
use std::{env, net, process};
6+
7+
use anyhow::{Context, anyhow, bail};
8+
use xshell::{Shell, cmd};
89

910
/// Used for rustc syncs.
1011
const JOSH_FILTER: &str = ":/src/doc/rustc-dev-guide";
@@ -15,10 +16,13 @@ pub enum RustcPullError {
1516
/// No changes are available to be pulled.
1617
NothingToPull,
1718
/// A rustc-pull has failed, probably a git operation error has occurred.
18-
PullFailed(anyhow::Error)
19+
PullFailed(anyhow::Error),
1920
}
2021

21-
impl<E> From<E> for RustcPullError where E: Into<anyhow::Error> {
22+
impl<E> From<E> for RustcPullError
23+
where
24+
E: Into<anyhow::Error>,
25+
{
2226
fn from(error: E) -> Self {
2327
Self::PullFailed(error.into())
2428
}
@@ -32,9 +36,7 @@ pub struct GitSync {
3236
/// (https://github.com/rust-lang/miri/blob/6a68a79f38064c3bc30617cca4bdbfb2c336b140/miri-script/src/commands.rs#L236).
3337
impl GitSync {
3438
pub fn from_current_dir() -> anyhow::Result<Self> {
35-
Ok(Self {
36-
dir: std::env::current_dir()?
37-
})
39+
Ok(Self { dir: std::env::current_dir()? })
3840
}
3941

4042
pub fn rustc_pull(&self, commit: Option<String>) -> Result<(), RustcPullError> {
@@ -51,7 +53,10 @@ impl GitSync {
5153
})?;
5254
// Make sure the repo is clean.
5355
if cmd!(sh, "git status --untracked-files=no --porcelain").read()?.is_empty().not() {
54-
return Err(anyhow::anyhow!("working directory must be clean before performing rustc pull").into());
56+
return Err(anyhow::anyhow!(
57+
"working directory must be clean before performing rustc pull"
58+
)
59+
.into());
5560
}
5661
// Make sure josh is running.
5762
let josh = Self::start_josh()?;
@@ -94,26 +99,33 @@ impl GitSync {
9499
};
95100
let num_roots_before = num_roots()?;
96101

97-
let sha = cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
102+
let sha =
103+
cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
98104

99105
// Merge the fetched commit.
100106
const MERGE_COMMIT_MESSAGE: &str = "Merge from rustc";
101107
cmd!(sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}")
102108
.run()
103109
.context("FAILED to merge new commits, something went wrong")?;
104110

105-
let current_sha = cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
111+
let current_sha =
112+
cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
106113
if current_sha == sha {
107114
cmd!(sh, "git reset --hard HEAD^")
108115
.run()
109116
.expect("FAILED to clean up after creating the preparation commit");
110-
eprintln!("No merge was performed, no changes to pull were found. Rolled back the preparation commit.");
117+
eprintln!(
118+
"No merge was performed, no changes to pull were found. Rolled back the preparation commit."
119+
);
111120
return Err(RustcPullError::NothingToPull);
112121
}
113122

114123
// Check that the number of roots did not increase.
115124
if num_roots()? != num_roots_before {
116-
return Err(anyhow::anyhow!("Josh created a new root commit. This is probably not the history you want.").into());
125+
return Err(anyhow::anyhow!(
126+
"Josh created a new root commit. This is probably not the history you want."
127+
)
128+
.into());
117129
}
118130

119131
drop(josh);

0 commit comments

Comments
 (0)