Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
chore: format code
Lars Wirzenius committed 6 months ago
commit 6bcf81400438044df0a11a564112fcdfbc9c381e
parent dd9347b
20 files changed +44 -47
modified src/adapter.rs
@@ -17,7 +17,7 @@ use std::{
};

use serde::Serialize;
-
use tempfile::{tempdir, TempDir};
+
use tempfile::{TempDir, tempdir};
use url::Url;

use crate::{
@@ -454,7 +454,7 @@ pub enum AdapterError {
mod test {
    use std::{fs::write, io::ErrorKind, path::PathBuf, time::Duration};

-
    use tempfile::{tempdir, NamedTempFile, TempDir};
+
    use tempfile::{NamedTempFile, TempDir, tempdir};

    use radicle::git::Oid;
    use radicle::prelude::RepoId;
@@ -465,7 +465,7 @@ mod test {
        msg::{MessageError, Response, RunId, RunResult},
        notif::NotificationChannel,
        run::{RunBuilder, Whence},
-
        test::{mock_adapter, trigger_request, TestResult},
+
        test::{TestResult, mock_adapter, trigger_request},
    };

    const MAX: Duration = Duration::from_secs(10);
modified src/bin/cibtool.rs
@@ -18,7 +18,7 @@ use std::{

use clap::Parser;

-
use radicle::{git::Oid, prelude::NodeId, Profile};
+
use radicle::{Profile, git::Oid, prelude::NodeId};

use radicle_ci_broker::{
    broker::BrokerError,
@@ -335,9 +335,7 @@ enum CibToolError {
    #[error("when adding a branch-update event, the --base option is required")]
    BaseRequired,

-
    #[error(
-
        "when adding a patch-create or patch--update event, the --patch-id option is required"
-
    )]
+
    #[error("when adding a patch-create or patch--update event, the --patch-id option is required")]
    PatchIdRequired,

    #[error("failed to construct a CI event")]
modified src/bin/cibtoolcmd/log.rs
@@ -1,6 +1,6 @@
use std::{
    convert::TryFrom,
-
    fs::{read, File},
+
    fs::{File, read},
    io::{Read, Write},
    path::{Path, PathBuf},
};
modified src/bin/synthetic-events.rs
@@ -7,7 +7,7 @@

use std::{
    env::current_exe,
-
    fs::{read, remove_file, File, OpenOptions},
+
    fs::{File, OpenOptions, read, remove_file},
    io::{Read, Write},
    net::Shutdown,
    os::unix::net::{UnixListener, UnixStream},
modified src/broker.rs
@@ -8,8 +8,8 @@ use std::{
    time::Duration,
};

-
use time::{macros::format_description, OffsetDateTime};
-
use tracing::{span, Level};
+
use time::{OffsetDateTime, macros::format_description};
+
use tracing::{Level, span};

use radicle::prelude::RepoId;

@@ -205,7 +205,7 @@ mod test {
        msg::{RunId, RunResult},
        notif::NotificationChannel,
        run::RunState,
-
        test::{mock_adapter, trigger_request, TestResult},
+
        test::{TestResult, mock_adapter, trigger_request},
    };

    fn broker(filename: &Path) -> anyhow::Result<Broker> {
modified src/ci_event.rs
@@ -12,7 +12,7 @@ use radicle::{
    storage::RefUpdate,
};

-
use crate::refs::{ref_string, GenericRefName, TagName};
+
use crate::refs::{GenericRefName, TagName, ref_string};

#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
#[non_exhaustive]
@@ -423,8 +423,7 @@ mod test {
    const MAIN_BRANCH_REF_NAME: &str =
        "refs/namespaces/z6MkiB8T5cBEQHnrs2MgjMVqvpSVj42X81HjKfFi2XBoMbtr/refs/heads/main";

-
    const PATCH_REF_NAME: &str =
-
        "refs/namespaces/z6MkiB8T5cBEQHnrs2MgjMVqvpSVj42X81HjKfFi2XBoMbtr/refs/heads/patches/f9fa90725474de9002be503ae3cda4670c9a174";
+
    const PATCH_REF_NAME: &str = "refs/namespaces/z6MkiB8T5cBEQHnrs2MgjMVqvpSVj42X81HjKfFi2XBoMbtr/refs/heads/patches/f9fa90725474de9002be503ae3cda4670c9a174";
    const PATCH_ID: &str = "f9fa90725474de9002be503ae3cda4670c9a174";

    fn nid() -> NodeId {
modified src/cob.rs
@@ -13,8 +13,8 @@ use uuid::Uuid;
use radicle::{
    git::Oid,
    node::{
-
        sync::{Announcer, AnnouncerConfig, ReplicationFactor},
        Handle, Node,
+
        sync::{Announcer, AnnouncerConfig, ReplicationFactor},
    },
    prelude::{Profile, ReadStorage, RepoId},
    storage::git::Repository,
modified src/db.rs
@@ -18,7 +18,7 @@ use std::{

use serde::{Deserialize, Serialize};
use sqlite::{Connection, State, Statement};
-
use time::{macros::format_description, OffsetDateTime};
+
use time::{OffsetDateTime, macros::format_description};
use uuid::Uuid;

use crate::{ci_event::CiEvent, msg::RunId, run::Run};
modified src/ergo.rs
@@ -8,11 +8,11 @@
use std::str::FromStr;

use radicle::{
-
    cob::patch::{cache::Patches, Patch, PatchId},
+
    cob::patch::{Patch, PatchId, cache::Patches},
    git::Oid,
    identity::{Project, RepoId},
    profile::Profile,
-
    storage::{git::Repository, ReadStorage, RepositoryInfo},
+
    storage::{ReadStorage, RepositoryInfo, git::Repository},
};

/// A Radicle node.
modified src/filter.rs
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};

use radicle::{
    cob::patch::PatchId,
-
    git::{raw::ObjectType, BranchName, Oid},
+
    git::{BranchName, Oid, raw::ObjectType},
    node::NodeId,
    prelude::{Profile, RepoId},
    storage::git::Repository,
@@ -418,7 +418,7 @@ mod test {
    use qcheck_macros::quickcheck;
    use radicle::prelude::{Did, RepoId};

-
    use crate::refs::{branch_from_str, TagName};
+
    use crate::refs::{TagName, branch_from_str};

    use super::*;

modified src/logger.rs
@@ -4,8 +4,8 @@ use std::{path::Path, process::ExitStatus, time::Duration};

use clap::ValueEnum;
use serde_json::Value;
-
use tracing::{debug, error, info, trace, warn, Level};
-
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
+
use tracing::{Level, debug, error, info, trace, warn};
+
use tracing_subscriber::{EnvFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt};
use uuid::Uuid;

use radicle::{git::Oid, identity::RepoId, node::Event, patch::PatchId};
modified src/msg.rs
@@ -20,17 +20,17 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use uuid::Uuid;

-
pub use radicle::{
-
    cob::patch::PatchId,
-
    git::Oid,
-
    prelude::{NodeId, RepoId},
-
};
use radicle::{
+
    Profile,
    identity::Did,
    node::{Alias, AliasStore},
    patch::{self, RevisionId},
-
    storage::{git::paths, ReadRepository, ReadStorage},
-
    Profile,
+
    storage::{ReadRepository, ReadStorage, git::paths},
+
};
+
pub use radicle::{
+
    cob::patch::PatchId,
+
    git::Oid,
+
    prelude::{NodeId, RepoId},
};

use crate::{
@@ -1266,10 +1266,10 @@ pub mod helper {
        process::Command,
    };

-
    use nonempty::{nonempty, NonEmpty};
+
    use nonempty::{NonEmpty, nonempty};
    use radicle::prelude::{Profile, RepoId};

-
    use time::{macros::format_description, OffsetDateTime};
+
    use time::{OffsetDateTime, macros::format_description};

    use super::{MessageError, Oid, Request, Response, RunId, RunResult};

modified src/node_event_source.rs
@@ -3,8 +3,8 @@
use std::{fmt, path::PathBuf, time};

use radicle::{
-
    node::{Event, Handle},
    Profile,
+
    node::{Event, Handle},
};

use crate::logger;
modified src/notif.rs
@@ -1,7 +1,7 @@
//! Notification channel between threads.

use std::{
-
    sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender},
+
    sync::mpsc::{Receiver, RecvTimeoutError, Sender, channel},
    time::Duration,
};

modified src/pages.rs
@@ -16,13 +16,13 @@ use std::{
use html_page::{Element, HtmlPage, Tag};
use rss::{Channel, ChannelBuilder, Guid, Item, ItemBuilder};
use serde::Serialize;
-
use time::{macros::format_description, OffsetDateTime};
+
use time::{OffsetDateTime, macros::format_description};

use radicle::{
+
    Profile,
    git::Oid,
    prelude::RepoId,
    storage::{ReadRepository, ReadStorage},
-
    Profile,
};

use crate::{
modified src/sensitive.rs
@@ -17,7 +17,7 @@

use std::fmt;

-
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
+
use serde::{Deserialize, Deserializer, Serialize, Serializer, de};

const PLACEHOLDER: &str = "<REDACTED>";

modified src/test.rs
@@ -7,13 +7,13 @@ use std::{
use crate::adapter::Adapter;
use crate::ci_event::{CiEvent, CiEventV1};
use crate::msg::{Request, RequestBuilder};
+
use radicle::Profile;
use radicle::crypto::ssh::Keystore;
use radicle::crypto::test::signer::MockSigner;
use radicle::git::RefString;
use radicle::profile::{Config, Home};
use radicle::storage::ReadRepository;
use radicle::test::setup::Node;
-
use radicle::Profile;

use tempfile::tempdir;

modified src/timeoutcmd.rs
@@ -50,12 +50,12 @@ use std::{
    io::{Read, Seek, Write},
    process::{Child, Command, ExitStatus, Stdio},
    sync::{
+
        Arc, Condvar, Mutex, MutexGuard,
        mpsc::{
-
            channel, sync_channel, Receiver, RecvTimeoutError, Sender, SyncSender, TryRecvError,
+
            Receiver, RecvTimeoutError, Sender, SyncSender, TryRecvError, channel, sync_channel,
        },
-
        Arc, Condvar, Mutex, MutexGuard,
    },
-
    thread::{sleep, spawn, JoinHandle},
+
    thread::{JoinHandle, sleep, spawn},
    time::{Duration, Instant},
};

@@ -705,8 +705,8 @@ mod tests {
    }

    #[test]
-
    fn sleep_for_too_long_while_reading_with_realtimelines(
-
    ) -> Result<(), Box<dyn std::error::Error>> {
+
    fn sleep_for_too_long_while_reading_with_realtimelines()
+
    -> Result<(), Box<dyn std::error::Error>> {
        let (running, mut stdout) = setup("exec sleep 1000", SHORT_TIMEOUT, None)?;
        while stdout.line().is_some() {}
        let result = running.wait();
modified src/util.rs
@@ -8,18 +8,18 @@ use std::{

use tempfile::NamedTempFile;
use time::{
-
    format_description::{well_known::Rfc2822, FormatItem},
+
    OffsetDateTime, PrimitiveDateTime,
+
    format_description::{FormatItem, well_known::Rfc2822},
    macros::format_description,
    parsing::Parsable,
-
    OffsetDateTime, PrimitiveDateTime,
};

use radicle::{
+
    Profile, Storage,
    cob::ObjectId,
    git::Oid,
    prelude::{NodeId, RepoId},
    storage::ReadStorage,
-
    Profile, Storage,
};

pub fn lookup_repo(profile: &Profile, wanted: &str) -> Result<(RepoId, String), UtilError> {
modified src/worker.rs
@@ -4,7 +4,7 @@
//! are implemented and used, as well as logging. A worker thread does
//! what it does. The abstraction is not meant to constrain that.

-
use std::thread::{spawn, JoinHandle};
+
use std::thread::{JoinHandle, spawn};

/// Start a new thread. Caller must catch the thread handle and
/// join it to wait for thread to end.