Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
remote-helper: refactor option handling
Lorenz Leutgeb committed 7 months ago
commit 0aa08e5a5c1911bc783a2afd13ace989ecafcbf6
parent 101c4c8863f8e967d21dfe5dc87c5dbc96896c3e
1 file changed +16 -20
modified crates/radicle-remote-helper/src/main.rs
@@ -231,10 +231,7 @@ pub fn run(profile: radicle::Profile) -> Result<(), Error> {
                push_option(args, &mut opts)?;
                println!("ok");
            }
-
            ["option", "progress", ..] => {
-
                println!("unsupported");
-
            }
-
            ["option", ..] => {
+
            ["option", "progress", ..] | ["option", ..] => {
                println!("unsupported");
            }
            ["fetch", oid, refstr] => {
@@ -297,22 +294,21 @@ fn push_option(args: &[&str], opts: &mut Options) -> Result<(), Error> {
        _ => {
            let args = args.join(" ");

-
            if let Some((key, val)) = args.split_once('=') {
-
                match key {
-
                    "patch.message" => {
-
                        opts.message.append(val);
-
                    }
-
                    "patch.base" => {
-
                        let base =
-
                            cli::args::rev(&val.into()).map_err(|e| Error::Base(e.into()))?;
-
                        opts.base = Some(base);
-
                    }
-
                    other => {
-
                        return Err(Error::UnsupportedPushOption(other.to_owned()));
-
                    }
+
            let (key, val) = args
+
                .split_once('=')
+
                .ok_or_else(|| Error::UnsupportedPushOption(args.to_owned()))?;
+

+
            match key {
+
                "patch.message" => {
+
                    opts.message.append(val);
+
                }
+
                "patch.base" => {
+
                    let base = cli::args::rev(&val.into()).map_err(|e| Error::Base(e.into()))?;
+
                    opts.base = Some(base);
+
                }
+
                other => {
+
                    return Err(Error::UnsupportedPushOption(other.to_owned()));
                }
-
            } else {
-
                return Err(Error::UnsupportedPushOption(args.to_owned()));
            }
        }
    }
@@ -374,4 +370,4 @@ pub(crate) fn patches_mut<'a>(
        }
        Err(err) => Err(err.into()),
    }
-
}

\ No newline at end of file
+
}