about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorTshepang Mbambo <tshepang@gmail.com>2025-05-10 13:35:33 +0200
committerTshepang Mbambo <tshepang@gmail.com>2025-05-10 13:47:31 +0200
commit63b3bf99afe22c299ed6ca332674cf2a63966e8e (patch)
tree94d00dfffa9e6704b6187f638846893fa8d798bd /src/doc
parenta9d655179f9e514860ae34f6b7e8448e142f0222 (diff)
downloadrust-63b3bf99afe22c299ed6ca332674cf2a63966e8e.tar.gz
rust-63b3bf99afe22c299ed6ca332674cf2a63966e8e.zip
"cargo fmt"
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/rustc-dev-guide/josh-sync/src/main.rs6
-rw-r--r--src/doc/rustc-dev-guide/josh-sync/src/sync.rs40
2 files changed, 28 insertions, 18 deletions
diff --git a/src/doc/rustc-dev-guide/josh-sync/src/main.rs b/src/doc/rustc-dev-guide/josh-sync/src/main.rs
index 175f016f739..aeedee5be22 100644
--- a/src/doc/rustc-dev-guide/josh-sync/src/main.rs
+++ b/src/doc/rustc-dev-guide/josh-sync/src/main.rs
@@ -1,4 +1,5 @@
 use clap::Parser;
+
 use crate::sync::{GitSync, RustcPullError};
 
 mod sync;
@@ -11,10 +12,7 @@ enum Args {
     /// Push changes from `rustc-dev-guide` to the given `branch` of a `rustc` fork under the given
     /// GitHub `username`.
     /// The pushed branch should then be merged into the `rustc` repository.
-    RustcPush {
-        branch: String,
-        github_username: String
-    }
+    RustcPush { branch: String, github_username: String },
 }
 
 fn main() -> anyhow::Result<()> {
diff --git a/src/doc/rustc-dev-guide/josh-sync/src/sync.rs b/src/doc/rustc-dev-guide/josh-sync/src/sync.rs
index 41d96397faa..ed38d1403a0 100644
--- a/src/doc/rustc-dev-guide/josh-sync/src/sync.rs
+++ b/src/doc/rustc-dev-guide/josh-sync/src/sync.rs
@@ -1,10 +1,11 @@
+use std::io::Write;
 use std::ops::Not;
 use std::path::PathBuf;
-use std::{env, net, process};
-use std::io::Write;
 use std::time::Duration;
-use anyhow::{anyhow, bail, Context};
-use xshell::{cmd, Shell};
+use std::{env, net, process};
+
+use anyhow::{Context, anyhow, bail};
+use xshell::{Shell, cmd};
 
 /// Used for rustc syncs.
 const JOSH_FILTER: &str = ":/src/doc/rustc-dev-guide";
@@ -15,10 +16,13 @@ pub enum RustcPullError {
     /// No changes are available to be pulled.
     NothingToPull,
     /// A rustc-pull has failed, probably a git operation error has occurred.
-    PullFailed(anyhow::Error)
+    PullFailed(anyhow::Error),
 }
 
-impl<E> From<E> for RustcPullError where E: Into<anyhow::Error> {
+impl<E> From<E> for RustcPullError
+where
+    E: Into<anyhow::Error>,
+{
     fn from(error: E) -> Self {
         Self::PullFailed(error.into())
     }
@@ -32,9 +36,7 @@ pub struct GitSync {
 /// (https://github.com/rust-lang/miri/blob/6a68a79f38064c3bc30617cca4bdbfb2c336b140/miri-script/src/commands.rs#L236).
 impl GitSync {
     pub fn from_current_dir() -> anyhow::Result<Self> {
-        Ok(Self {
-            dir: std::env::current_dir()?
-        })
+        Ok(Self { dir: std::env::current_dir()? })
     }
 
     pub fn rustc_pull(&self, commit: Option<String>) -> Result<(), RustcPullError> {
@@ -51,7 +53,10 @@ impl GitSync {
         })?;
         // Make sure the repo is clean.
         if cmd!(sh, "git status --untracked-files=no --porcelain").read()?.is_empty().not() {
-            return Err(anyhow::anyhow!("working directory must be clean before performing rustc pull").into());
+            return Err(anyhow::anyhow!(
+                "working directory must be clean before performing rustc pull"
+            )
+            .into());
         }
         // Make sure josh is running.
         let josh = Self::start_josh()?;
@@ -94,7 +99,8 @@ impl GitSync {
         };
         let num_roots_before = num_roots()?;
 
-        let sha = cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
+        let sha =
+            cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
 
         // Merge the fetched commit.
         const MERGE_COMMIT_MESSAGE: &str = "Merge from rustc";
@@ -102,18 +108,24 @@ impl GitSync {
             .run()
             .context("FAILED to merge new commits, something went wrong")?;
 
-        let current_sha = cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
+        let current_sha =
+            cmd!(sh, "git rev-parse HEAD").output().context("FAILED to get current commit")?.stdout;
         if current_sha == sha {
             cmd!(sh, "git reset --hard HEAD^")
                 .run()
                 .expect("FAILED to clean up after creating the preparation commit");
-            eprintln!("No merge was performed, no changes to pull were found. Rolled back the preparation commit.");
+            eprintln!(
+                "No merge was performed, no changes to pull were found. Rolled back the preparation commit."
+            );
             return Err(RustcPullError::NothingToPull);
         }
 
         // Check that the number of roots did not increase.
         if num_roots()? != num_roots_before {
-            return Err(anyhow::anyhow!("Josh created a new root commit. This is probably not the history you want.").into());
+            return Err(anyhow::anyhow!(
+                "Josh created a new root commit. This is probably not the history you want."
+            )
+            .into());
         }
 
         drop(josh);